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