我已经列举了关于“在shared_memory中创建向量”的boost样本。 现在我的数据结构是这样的:如何通过boost :: interprocess构建向量中的向量
数据结构:
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函数调用。
看来你在C++语言中遇到了麻烦。没关系。但是我建议_不要使用C++的进程间技术,除非你必须同时学习这两个复杂的主题。 (我非常确定,例如[tag:python]或[tag:c#-4.0]将具有处理大型数据集所需的工具。) – sehe
如果这仅仅是大型数据集,[STXXL](http:///stxxl.sourceforge.net/)可能对您有些用处。 – wilx