2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
34 1998-7-13 Godfrey van der Linden(gvdl)
36 1998-10-30 Godfrey van der Linden(gvdl)
38 1999-9-22 Godfrey van der Linden(gvdl)
41 #ifndef _IOKIT_IOCOMMANDQUEUE_H
42 #define _IOKIT_IOCOMMANDQUEUE_H
44 #include <IOKit/IOEventSource.h>
49 #warning IOCommandQueue has been deprecated in favour of IOCommandGate and will be going away before too long.
57 typedef void (*IOCommandQueueAction
)
58 (OSObject
*, void *field0
, void *field1
, void *field2
, void *field3
);
60 class IOCommandQueue
: public IOEventSource
62 OSDeclareDefaultStructors(IOCommandQueue
)
65 static const int kIOCQDefaultSize
= 128;
69 semaphore_port_t producerSema
;
70 int producerIndex
, consumerIndex
;
75 virtual bool checkForWork();
78 static IOCommandQueue
*commandQueue(OSObject
*inOwner
,
79 IOCommandQueueAction inAction
= 0,
80 int inSize
= kIOCQDefaultSize
);
81 virtual bool init(OSObject
*inOwner
,
82 IOCommandQueueAction inAction
= 0,
83 int inSize
= kIOCQDefaultSize
);
85 virtual kern_return_t
enqueueCommand(bool gotoSleep
= true,
86 void *field0
= 0, void *field1
= 0,
87 void *field2
= 0, void *field3
= 0);
89 // WARNING: This function can only be safely called from the appropriate
90 // work loop context. You should check IOWorkLoop::onThread is true.
92 // For each entry in the commandQueue call the target/action.
93 // Lockout all new entries to the queue while iterating.
94 // If the input fields are zero then the queue's owner/action will be used.
95 virtual int performAndFlush(OSObject
*target
= 0,
96 IOCommandQueueAction inAction
= 0);
99 #endif /* !_IOKIT_IOCOMMANDQUEUE_H */