00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <iostream>
00021
00022 #include <archon/x3d/proxy/disposer.H>
00023
00024 namespace Archon
00025 {
00026 namespace X3D
00027 {
00028 namespace Proxy
00029 {
00030 Disposer::Disposer(x3d::sai::Session_ptr ref):
00031 more(disposerMutex)
00032 {
00033 session = x3d::sai::Session::_duplicate(ref);
00034 }
00035
00036 Disposer::~Disposer()
00037 {
00038 }
00039
00040 void Disposer::addContext(unsigned long id, unsigned long transCount)
00041 {
00042 {
00043 Mutex::Lock l(disposerMutex);
00044 contexts.push_back(Entry(id, transCount));
00045 }
00046 more.notifyAll();
00047 }
00048
00049
00050 void Disposer::addNode(unsigned long id, unsigned long transCount)
00051 {
00052 {
00053 Mutex::Lock l(disposerMutex);
00054 nodes.push_back(Entry(id, transCount));
00055 }
00056 more.notifyAll();
00057 }
00058
00059 void Disposer::main()
00060 {
00061 for(;;)
00062 {
00063 vector<Entry> c, n;
00064 {
00065 Mutex::Lock l(disposerMutex);
00066 while(!contexts.size() && !nodes.size()) more.wait();
00067 swap(contexts, c);
00068 swap(nodes, n);
00069 }
00070
00071 x3d::sai::DisposeSeq cs(c.size());
00072 cs.length(c.size());
00073 for(unsigned i=0; i<c.size(); ++i)
00074 {
00075 Entry &e = c[i];
00076 x3d::sai::DisposeEntry &f = cs[i];
00077 f.id = e.id;
00078 f.transCount = e.transCount;
00079 }
00080
00081 x3d::sai::DisposeSeq ns(n.size());
00082 ns.length(n.size());
00083 for(unsigned i=0; i<n.size(); ++i)
00084 {
00085 Entry &e = n[i];
00086 x3d::sai::DisposeEntry &f = ns[i];
00087 f.id = e.id;
00088 f.transCount = e.transCount;
00089 }
00090
00091 session->disposeBatch(cs, ns);
00092 }
00093 }
00094 }
00095 }
00096 }