MCPcopy Create free account
hub / github.com/anjo76/angelscript / AcquireExclusive

Method AcquireExclusive

sdk/angelscript/source/as_thread.cpp:412–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410}
411
412void asCThreadReadWriteLock::AcquireExclusive()
413{
414#if defined AS_POSIX_THREADS
415 pthread_rwlock_wrlock(&lock);
416#elif defined AS_WINDOWS_THREADS
417 // Synchronize writers, so only one tries to lock out the readers
418 EnterCriticalSection(&writeLock);
419
420 // Lock all reader out from the semaphore. Do this one by one,
421 // so the lock doesn't have to wait until there are no readers at all.
422 // If we try to lock all at once it is quite possible the writer will
423 // never succeed.
424 for( asUINT n = 0; n < maxReaders; n++ )
425 WaitForSingleObjectEx(readLocks, INFINITE, FALSE);
426
427 // Allow another writer to lock. It will only be able to
428 // lock the readers when this writer releases them anyway.
429 LeaveCriticalSection(&writeLock);
430#endif
431}
432
433void asCThreadReadWriteLock::ReleaseExclusive()
434{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected