我已經列舉了關於「在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