]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
ff6e181a A |
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. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
1c79356b | 12 | * |
ff6e181a A |
13 | * The Original Code and all software distributed under the License are |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
ff6e181a A |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
1c79356b A |
20 | * |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | /* | |
24 | Copyright (c) 1998 Apple Computer, Inc. All rights reserved. | |
25 | ||
26 | HISTORY | |
27 | 1998-7-13 Godfrey van der Linden(gvdl) | |
28 | Created. | |
29 | ]*/ | |
30 | #include <IOKit/IOLib.h> | |
31 | ||
32 | #include <IOKit/IOEventSource.h> | |
33 | #include <IOKit/IOWorkLoop.h> | |
34 | ||
35 | #define super OSObject | |
36 | ||
37 | OSDefineMetaClassAndAbstractStructors(IOEventSource, OSObject) | |
38 | OSMetaClassDefineReservedUnused(IOEventSource, 0); | |
39 | OSMetaClassDefineReservedUnused(IOEventSource, 1); | |
40 | OSMetaClassDefineReservedUnused(IOEventSource, 2); | |
41 | OSMetaClassDefineReservedUnused(IOEventSource, 3); | |
42 | OSMetaClassDefineReservedUnused(IOEventSource, 4); | |
43 | OSMetaClassDefineReservedUnused(IOEventSource, 5); | |
44 | OSMetaClassDefineReservedUnused(IOEventSource, 6); | |
45 | OSMetaClassDefineReservedUnused(IOEventSource, 7); | |
46 | ||
9bccf70c A |
47 | /* inline function implementations */ |
48 | void IOEventSource::signalWorkAvailable() { workLoop->signalWorkAvailable(); } | |
49 | void IOEventSource::openGate() { workLoop->openGate(); } | |
50 | void IOEventSource::closeGate() { workLoop->closeGate(); } | |
51 | bool IOEventSource::tryCloseGate() { return workLoop->tryCloseGate(); } | |
52 | int IOEventSource::sleepGate(void *event, UInt32 type) | |
53 | { return workLoop->sleepGate(event, type); } | |
54 | void IOEventSource::wakeupGate(void *event, bool oneThread) | |
55 | { workLoop->wakeupGate(event, oneThread); } | |
56 | ||
1c79356b | 57 | bool IOEventSource::init(OSObject *inOwner, |
55e303ae | 58 | Action inAction) |
1c79356b A |
59 | { |
60 | if (!inOwner) | |
61 | return false; | |
62 | ||
63 | owner = inOwner; | |
64 | ||
65 | if ( !super::init() ) | |
66 | return false; | |
67 | ||
68 | (void) setAction(inAction); | |
69 | enabled = true; | |
70 | ||
71 | return true; | |
72 | } | |
73 | ||
74 | IOEventSource::Action IOEventSource::getAction () const { return action; }; | |
75 | ||
76 | void IOEventSource::setAction(Action inAction) | |
77 | { | |
78 | action = inAction; | |
79 | } | |
80 | ||
81 | IOEventSource *IOEventSource::getNext() const { return eventChainNext; }; | |
82 | ||
83 | void IOEventSource::setNext(IOEventSource *inNext) | |
84 | { | |
85 | eventChainNext = inNext; | |
86 | } | |
87 | ||
88 | void IOEventSource::enable() | |
89 | { | |
90 | enabled = true; | |
91 | if (workLoop) | |
92 | return signalWorkAvailable(); | |
93 | } | |
94 | ||
95 | void IOEventSource::disable() | |
96 | { | |
97 | enabled = false; | |
98 | } | |
99 | ||
100 | bool IOEventSource::isEnabled() const | |
101 | { | |
102 | return enabled; | |
103 | } | |
104 | ||
105 | void IOEventSource::setWorkLoop(IOWorkLoop *inWorkLoop) | |
106 | { | |
107 | if ( !inWorkLoop ) | |
108 | disable(); | |
109 | workLoop = inWorkLoop; | |
110 | } | |
111 | ||
112 | IOWorkLoop *IOEventSource::getWorkLoop() const | |
113 | { | |
114 | return workLoop; | |
115 | } | |
116 | ||
117 | bool IOEventSource::onThread() const | |
118 | { | |
119 | return (workLoop != 0) && workLoop->onThread(); | |
120 | } |