]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
6601e61a | 4 | * @APPLE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
6601e61a A |
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. | |
8f6c56a5 | 11 | * |
6601e61a A |
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 | |
8f6c56a5 A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
6601e61a A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
8f6c56a5 | 19 | * |
6601e61a | 20 | * @APPLE_LICENSE_HEADER_END@ |
1c79356b A |
21 | */ |
22 | /* | |
23 | Copyright (c) 1998 Apple Computer, Inc. All rights reserved. | |
24 | ||
25 | HISTORY | |
26 | 1998-7-13 Godfrey van der Linden(gvdl) | |
27 | Created. | |
28 | 1998-10-30 Godfrey van der Linden(gvdl) | |
29 | Converted to C++ | |
30 | 1999-9-22 Godfrey van der Linden(gvdl) | |
31 | Deprecated | |
32 | ]*/ | |
33 | #ifndef _IOKIT_IOCOMMANDQUEUE_H | |
34 | #define _IOKIT_IOCOMMANDQUEUE_H | |
35 | ||
36 | #include <IOKit/IOEventSource.h> | |
37 | ||
38 | ||
39 | ||
40 | ||
41 | #warning IOCommandQueue has been deprecated in favour of IOCommandGate and will be going away before too long. | |
42 | ||
43 | ||
44 | ||
45 | ||
46 | ||
47 | class IOCommandQueue; | |
48 | ||
49 | typedef void (*IOCommandQueueAction) | |
50 | (OSObject *, void *field0, void *field1, void *field2, void *field3); | |
51 | ||
52 | class IOCommandQueue : public IOEventSource | |
53 | { | |
54 | OSDeclareDefaultStructors(IOCommandQueue) | |
55 | ||
56 | protected: | |
57 | static const int kIOCQDefaultSize = 128; | |
58 | ||
59 | void *queue; | |
60 | IOLock *producerLock; | |
61 | semaphore_port_t producerSema; | |
62 | int producerIndex, consumerIndex; | |
63 | int size; | |
64 | ||
65 | virtual void free(); | |
66 | ||
67 | virtual bool checkForWork(); | |
68 | ||
69 | public: | |
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); | |
76 | ||
77 | virtual kern_return_t enqueueCommand(bool gotoSleep = true, | |
78 | void *field0 = 0, void *field1 = 0, | |
79 | void *field2 = 0, void *field3 = 0); | |
80 | ||
81 | // WARNING: This function can only be safely called from the appropriate | |
82 | // work loop context. You should check IOWorkLoop::onThread is true. | |
83 | // | |
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); | |
89 | }; | |
90 | ||
91 | #endif /* !_IOKIT_IOCOMMANDQUEUE_H */ |