| 410 | } |
| 411 | |
| 412 | void 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 | |
| 433 | void asCThreadReadWriteLock::ReleaseExclusive() |
| 434 | { |
nothing calls this directly
no outgoing calls
no test coverage detected