【发布时间】:2014-01-08 05:55:46
【问题描述】:
我已经了解了有关“在 shared_memory 中创建向量”的 boost 示例。 现在我的数据结构是这样的:
数据结构:
enum FuncIndex
{
enmFunc_glBegin,
...
}
class CGLParam {};
class Funcall
{
vector<CGLParam> vecParams;
};
class Global_Funcall
{
typedef allocator<CGLParam*, managed_shared_memory::segment_manager> ShmemAllocator;
typedef vector<CGLParam*, ShmemAllocator> MyVector;
MyVector<FunCall> vecFuncalls;
};
Global_Funcall()
{
shared_memory_object::remove("MySharedMemory");
managed_shared_memory segment(create_only, "MySharedMemory", 65536);
//Initialize shared memory STL-compatible allocator
const ShmemAllocator alloc_inst(segment.get_segment_manager());
//Construct a vector named "MyVector" in shared memory with argument alloc_inst
vecFuncalls= segment.construct<MyVector>("MyVector")(alloc_inst);
}
void InvokeFuncs(CGLParam *presult)
{
managed_shared_memory open_segment(open_only,"MySharedMemory");
listParams = open_segment.find<MyVector>("MyVector").first;
// MyVector::const_iterator it;
// for (it = listParams->cbegin(); it != listParams->cend(); it++)
// {
// (*it)->InvokeFunc(presult);
// }
}
我的问题是“如何构造 vecParams 以及如何获取它”。数据量很大(opengl 函数调用) 该结构用于保存opengl函数调用。
【问题讨论】:
-
如果这只是关于大型数据集,STXXL 可能对您有用。
标签: boost interprocess boost-interprocess inter-process-communicat