2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
29 1998-7-13 Godfrey van der Linden(gvdl)
31 1998-10-30 Godfrey van der Linden(gvdl)
33 1999-9-22 Godfrey van der Linden(gvdl)
36 #ifndef _IOKIT_IOCOMMANDQUEUE_H
37 #define _IOKIT_IOCOMMANDQUEUE_H
39 #include <IOKit/IOEventSource.h>
44 #warning IOCommandQueue has been deprecated in favour of IOCommandGate and will be going away before too long.
52 typedef void (*IOCommandQueueAction
)
53 (OSObject
*, void *field0
, void *field1
, void *field2
, void *field3
);
55 class IOCommandQueue
: public IOEventSource
57 OSDeclareDefaultStructors(IOCommandQueue
)
60 static const int kIOCQDefaultSize
= 128;
64 semaphore_port_t producerSema
;
65 int producerIndex
, consumerIndex
;
70 virtual bool checkForWork();
73 static IOCommandQueue
*commandQueue(OSObject
*inOwner
,
74 IOCommandQueueAction inAction
= 0,
75 int inSize
= kIOCQDefaultSize
);
76 virtual bool init(OSObject
*inOwner
,
77 IOCommandQueueAction inAction
= 0,
78 int inSize
= kIOCQDefaultSize
);
80 virtual kern_return_t
enqueueCommand(bool gotoSleep
= true,
81 void *field0
= 0, void *field1
= 0,
82 void *field2
= 0, void *field3
= 0);
84 // WARNING: This function can only be safely called from the appropriate
85 // work loop context. You should check IOWorkLoop::onThread is true.
87 // For each entry in the commandQueue call the target/action.
88 // Lockout all new entries to the queue while iterating.
89 // If the input fields are zero then the queue's owner/action will be used.
90 virtual int performAndFlush(OSObject
*target
= 0,
91 IOCommandQueueAction inAction
= 0);
94 #endif /* !_IOKIT_IOCOMMANDQUEUE_H */