Vuo  2.0.0
VuoRuntimePersistentState.cc
Go to the documentation of this file.
1 
11 
12 #include "VuoCompositionDiff.hh"
13 #include "VuoNodeRegistry.hh"
15 #include "VuoRuntimeState.hh"
16 #include "VuoThreadManager.hh"
17 
22 {
23  this->workingDirectory = (strlen(workingDirectory) > 0 ? workingDirectory : getCurrentWorkingDirectory());
24 
25  lastEventId = 0;
26 
27  _isStopRequested = false;
28 
29  finiCallbackQueue = dispatch_queue_create("org.vuo.runtime.finiCallback", NULL);
30 
31  triggerWorkersScheduled = dispatch_group_create();
32 
34  nodeRegistry = new VuoNodeRegistry(this);
37 }
38 
43 {
44  dispatch_release(finiCallbackQueue);
45  dispatch_release(triggerWorkersScheduled);
46 
47  delete compositionDiff;
48  delete nodeRegistry;
49  delete communicator;
50  delete threadManager;
51 }
52 
57 {
58  // Keep consistent with VuoGetWorkingDirectory().
59  char currentWorkingDirectory[PATH_MAX+1];
60  getcwd(currentWorkingDirectory, PATH_MAX+1);
61  return currentWorkingDirectory;
62 }
63 
68 {
69  return strdup(workingDirectory.c_str());
70 }
71 
76 {
77  return __sync_add_and_fetch(&lastEventId, 1);
78 }
79 
84 {
85  return _isStopRequested;
86 }
87 
92 {
93  _isStopRequested = isStopRequested;
94 }
95 
100 {
101  dispatch_sync(finiCallbackQueue, ^{
102  finiCallbacks.push_back(fini);
103  });
104 }
105 
110 {
111  dispatch_sync(finiCallbackQueue, ^{
112  VuoCompositionState compositionState = { (void *)runtimeState, "" };
114 
115  for (vector<VuoCompositionFiniCallback>::iterator i = finiCallbacks.begin(); i != finiCallbacks.end(); ++i)
116  (*i)();
117 
119  });
120 }
121 
127 {
128  return triggerWorkersScheduled;
129 }
130 
131 extern "C"
132 {
133 
137 unsigned long vuoGetNextEventId(VuoCompositionState *compositionState)
138 {
141 }
142 
146 dispatch_group_t vuoGetTriggerWorkersScheduled(VuoCompositionState *compositionState)
147 {
150 }
151 
152 }