home *** CD-ROM | disk | FTP | other *** search
- /*
- * $Id: CJRLock.h,v 1.1 1997/04/02 18:28:20 croehrig Exp $
- *
- * CJRLock -- Foundation Kit-less NSLock, NSConditionLock
- * Compatibile with Foundation Kit from EOF 1.1, which shipped with
- * NS3.3 Academic Bundle).
- *
- * (c) 1997 Chris Roehrig <croehrig@House.ORG>
- *
- * Doesn't implement timeout methods.
- * Doesn't implement NSRecursiveLock.
- */
-
- #import <objc/Object.h>
- #import <mach/cthreads.h>
-
- @protocol CJRLocking
- - (void)lock;
- - (void)unlock;
- @end
-
-
- /*************** CJRLock ***************/
-
- @interface CJRLock:Object <CJRLocking> {
- @private
- mutex_t mutex;
- }
-
- - (BOOL)tryLock;
- /* Returns YES iff lock acquired; returns immediately */
-
- @end
-
-
- /*************** CJRConditionLock ***************/
-
-
- @interface CJRConditionLock:Object <CJRLocking> {
- @private
- mutex_t mutex; // lock to protect data
- volatile int data;
- condition_t cond;
- }
-
- - initWithCondition:(int)condition;
- // init & set condition variable
-
- - (int)condition;
-
- - (void)lockWhenCondition:(int)condition;
- // acquire lock when conditionVar == condition
-
- - (BOOL)tryLock;
- /* Returns YES iff lock acquired; returns immediately */
-
- - (BOOL)tryLockWhenCondition:(int)condition;
- // acquire lock when conditionVar == condition
-
- - (void)unlockWithCondition:(int)condition;
- // release lock and update conditionVar
-
- @end
-