MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / Prepare

Method Prepare

src/server/angelscript/angelscript/source/as_thread.cpp:139–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139int asCThreadManager::Prepare(asIThreadManager *externalThreadMgr)
140{
141 // Don't allow an external thread manager if there
142 // is already a thread manager defined
143 if( externalThreadMgr && threadManager )
144 return asINVALID_ARG;
145
146 // The critical section cannot be declared globally, as there is no
147 // guarantee for the order in which global variables are initialized
148 // or uninitialized.
149
150 // For this reason it's not possible to prevent two threads from calling
151 // AddRef at the same time, so there is a chance for a race condition here.
152
153 // To avoid the race condition when the thread manager is first created,
154 // the application must make sure to call the global asPrepareForMultiThread()
155 // in the main thread before any other thread creates a script engine.
156 if( threadManager == 0 && externalThreadMgr == 0 )
157 threadManager = asNEW(asCThreadManager);
158 else
159 {
160 // If an application uses different dlls each dll will get it's own memory
161 // space for global variables. If multiple dlls then uses AngelScript's
162 // global thread support functions it is then best to share the thread
163 // manager to make sure all dlls use the same critical section.
164 if( externalThreadMgr )
165 threadManager = reinterpret_cast<asCThreadManager*>(externalThreadMgr);
166
167 ENTERCRITICALSECTION(threadManager->criticalSection);
168 threadManager->refCount++;
169 LEAVECRITICALSECTION(threadManager->criticalSection);
170 }
171
172 // Success
173 return 0;
174}
175
176void asCThreadManager::Unprepare()
177{

Callers 15

runAppMethod · 0.45
RunApplicationFunction · 0.45
mainFunction · 0.45
RunApplicationFunction · 0.45
ScriptObjectCopyFactoryFunction · 0.45
CallDestructorMethod · 0.45
CopyFromAsMethod · 0.45
RefCastObjectMethod · 0.45
InitGlobalPropMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected