Functions | |
AS_API int | asPrepareMultithread (asIThreadManager *externalMgr=0) |
Sets up the internally shared resources for multithreading. More... | |
AS_API void | asUnprepareMultithread () |
Frees resources prepared for multithreading. More... | |
AS_API asIThreadManager * | asGetThreadManager () |
Get the thread manager used by the application. More... | |
AS_API void | asAcquireExclusiveLock () |
Acquire an exclusive lock. More... | |
AS_API void | asReleaseExclusiveLock () |
Release an exclusive lock. More... | |
AS_API void | asAcquireSharedLock () |
Acquire a shared lock. More... | |
AS_API void | asReleaseSharedLock () |
Release a shared lock. More... | |
AS_API int | asAtomicInc (int &value) |
Increments the value by one and returns the result as a single atomic instruction. More... | |
AS_API int | asAtomicDec (int &value) |
Decrements the value by one and returns the result as a single atomic instruction. More... | |
AS_API int | asThreadCleanup () |
Cleans up memory allocated for the current thread. More... | |
AS_API asILockableSharedBool * | asCreateLockableSharedBool () |
Create a lockable shared boolean. More... | |
AS_API void asAcquireExclusiveLock | ( | ) |
This function will block the calling thread until there are no other threads that hold shared or exclusive locks.
AS_API void asAcquireSharedLock | ( | ) |
This function will block the calling thread until there are no other threads that hold exclusive locks. Other threads may hold shared locks.
AS_API int asAtomicDec | ( | int & | value | ) |
[in] | value | A reference to the value that should be decremented |
This function is especially useful for implementing thread safe reference counters.
AS_API int asAtomicInc | ( | int & | value | ) |
[in] | value | A reference to the value that should be incremented |
This function is especially useful for implementing thread safe reference counters.
AS_API asILockableSharedBool* asCreateLockableSharedBool | ( | ) |
The lockable shared boolean will be created with an initial reference count of 1, and the boolean value false.
The object can be used for weak reference flags.
AS_API asIThreadManager* asGetThreadManager | ( | ) |
AS_API int asPrepareMultithread | ( | asIThreadManager * | externalMgr = 0 | ) |
[in] | externalMgr | Pre-existent thread manager (optional) |
asINVALID_ARG | externalMgr informed even though local manager already exists |
Call this function from the main thread to set up shared resources for multithreading if engines are to be created in multiple threads.
If multiple modules (dlls) are used it may be necessary to call this with the thread manager retrieved from asGetThreadManager() in the main module in order for all modules to share the same thread manager.
AS_API void asReleaseExclusiveLock | ( | ) |
Releases the previously acquired exclusive lock.
AS_API void asReleaseSharedLock | ( | ) |
Releases the previously acquired shared lock.
AS_API int asThreadCleanup | ( | ) |
asCONTEXT_ACTIVE | A context is still active. |
Call this function before terminating a thread that has accessed the engine to clean up memory allocated for that thread.
It's not necessary to call this if only a single thread accesses the engine.
AS_API void asUnprepareMultithread | ( | ) |
If asPrepareMultithread() has been called, then this function should be called after the last engine has been released to free the resources prepared for multithreading.