]>
git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOConditionLock.h
02c16e2647c9fe901c3337401f65957e1643c7a3
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 /* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
24 * Copyright (c) 1994-1996 NeXT Software, Inc. All rights reserved.
27 #ifndef _IOKIT_IOCONDITIONLOCK_H
28 #define _IOKIT_IOCONDITIONLOCK_H
30 #include <libkern/c++/OSObject.h>
31 #include <IOKit/IOLib.h>
32 #include <IOKit/system.h>
34 #include <IOKit/IOLocks.h>
36 class IOConditionLock
: public OSObject
38 OSDeclareDefaultStructors(IOConditionLock
)
41 IOLock
* cond_interlock
; // condition var Simple lock
42 volatile int condition
;
44 IOLock
* sleep_interlock
; // sleep lock Simple lock
45 unsigned char interruptible
;
46 volatile bool want_lock
;
47 volatile bool waiting
;
50 static IOConditionLock
*withCondition(int condition
, bool inIntr
= true);
51 virtual bool initWithCondition(int condition
, bool inIntr
= true);
54 virtual bool tryLock(); // acquire lock, no waiting
55 virtual int lock(); // acquire lock (enter critical section)
56 virtual void unlock(); // release lock (leave critical section)
58 virtual bool getInterruptible() const;
59 virtual int getCondition() const;
60 virtual int setCondition(int condition
);
62 virtual int lockWhen(int condition
); // acquire lock when condition
63 virtual void unlockWith(int condition
); // set condition & release lock
66 #endif /* _IOKIT_IOCONDITIONLOCK_H */