]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
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. | |
11 | * | |
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 | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_END@ | |
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 */ |