3 Copyright 1999, Be Incorporated. All Rights Reserved.
4 This file may be used under the terms of the Be Sample Code License.
7 /* multiple-reader single-writer locking class */
10 #define MULTI_LOCKER_H
16 const int32 LARGE_NUMBER
= 100000;
20 MultiLocker(const char* semaphoreBaseName
);
21 virtual ~MultiLocker();
25 //locking for reading or writing
29 //unlocking after reading or writing
33 //does the current thread hold a write lock ?
34 bool IsWriteLocked(uint32
*stack_base
= NULL
, thread_id
*thread
= NULL
);
35 //in DEBUG mode returns whether the lock is held
36 //in non-debug mode returns true
40 //functions for managing the DEBUG reader array
41 void register_thread();
42 void unregister_thread();
45 //readers adjust count and block on fReadSem when a writer
49 //writers adjust the count and block on fWriteSem
50 //when readers hold the lock
53 //writers must acquire fWriterLock when acquiring a write lock
58 thread_id fWriterThread
;
59 uint32 fWriterStackBase
;
74 bigtime_t islock_time
;
82 class AutoWriteLocker
{
84 AutoWriteLocker(MultiLocker
* lock
)
97 class AutoReadLocker
{
99 AutoReadLocker(MultiLocker
* lock
)