ObjFW
OFKernelEventObserver.h
1 /*
2  * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFObject.h"
17 
18 #ifdef OF_HAVE_SOCKETS
19 # import "socket.h"
20 #endif
21 
22 #ifdef OF_AMIGAOS
23 # include <exec/types.h>
24 # include <exec/tasks.h>
25 #endif
26 
27 OF_ASSUME_NONNULL_BEGIN
28 
29 @class OFMutableArray OF_GENERIC(ObjectType);
30 @class OFDate;
31 #ifdef OF_HAVE_THREADS
32 @class OFMutex;
33 #endif
34 @class OFMutableData;
35 
44 @optional
59 - (void)objectIsReadyForReading: (id)object;
60 
66 - (void)objectIsReadyForWriting: (id)object;
67 
68 #ifdef OF_AMIGAOS
74 - (void)execSignalWasReceived: (ULONG)signalMask;
75 #endif
76 @end
77 
90 @property (readonly, nonatomic) int fileDescriptorForReading;
91 @end
92 
105 @property (readonly, nonatomic) int fileDescriptorForWriting;
106 @end
107 
108 #ifdef OF_HAVE_SOCKETS
119 {
121  *_readObjects;
123  *_writeObjects;
124  id <OFKernelEventObserverDelegate> _Nullable _delegate;
125 #if defined(OF_AMIGAOS)
126  struct Task *_waitingTask;
127  ULONG _cancelSignal;
128 #elif defined(OF_HAVE_PIPE)
129  int _cancelFD[2];
130 #else
131  of_socket_t _cancelFD[2];
132  struct sockaddr_in _cancelAddr;
133 #endif
134 #ifdef OF_AMIGAOS
135  ULONG _execSignalMask;
136 #endif
137  OF_RESERVE_IVARS(OFKernelEventObserver, 4)
138 }
139 
143 @property OF_NULLABLE_PROPERTY (assign, nonatomic)
145 
146 #ifdef OF_AMIGAOS
152 @property (nonatomic) ULONG execSignalMask;
153 #endif
154 
160 + (instancetype)observer;
161 
173 - (void)addObjectForReading: (id <OFReadyForReadingObserving>)object;
174 
183 - (void)addObjectForWriting: (id <OFReadyForWritingObserving>)object;
184 
193 - (void)removeObjectForReading: (id <OFReadyForReadingObserving>)object;
194 
203 - (void)removeObjectForWriting: (id <OFReadyForWritingObserving>)object;
204 
208 - (void)observe;
209 
216 - (void)observeForTimeInterval: (of_time_interval_t)timeInterval;
217 
224 - (void)observeUntilDate: (OFDate *)date;
225 
232 - (void)cancel;
233 
239 - (bool)of_processReadBuffers;
240 @end
241 #endif
242 
243 OF_ASSUME_NONNULL_END
double of_time_interval_t
A time interval in seconds.
Definition: OFObject.h:138
struct objc_object * id
A pointer to any object.
Definition: ObjFWRT.h:90
A class for storing, accessing and comparing dates.
Definition: OFDate.h:36
A class that can observe multiple kernel events (e.g. streams being ready to read) at once.
Definition: OFKernelEventObserver.h:119
An abstract class for storing, adding and removing objects in an array.
Definition: OFMutableArray.h:44
A class for storing and manipulating arbitrary data in an array.
Definition: OFMutableData.h:29
A class for creating mutual exclusions.
Definition: OFMutex.h:30
The root class for all other classes inside ObjFW.
Definition: OFObject.h:520
A protocol that needs to be implemented by delegates for OFKernelEventObserver.
Definition: OFKernelEventObserver.h:43
This protocol is implemented by classes which can be observed for readiness for reading by OFKernelEv...
Definition: OFKernelEventObserver.h:85
int fileDescriptorForReading
The file descriptor for reading that should be checked by the OFKernelEventObserver.
Definition: OFKernelEventObserver.h:90
This protocol is implemented by classes which can be observed for readiness for writing by OFKernelEv...
Definition: OFKernelEventObserver.h:100
int fileDescriptorForWriting
The file descriptor for writing that should be checked by the OFKernelEventObserver.
Definition: OFKernelEventObserver.h:105