ObjFW
Loading...
Searching...
No Matches
OFKernelEventObserver.h
1/*
2 * Copyright (c) 2008-2024 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#ifdef OF_HAVE_SOCKETS
18# import "OFSocket.h"
19#endif
20
21#ifdef OF_AMIGAOS
22# include <exec/types.h>
23# include <exec/tasks.h>
24#endif
25
26OF_ASSUME_NONNULL_BEGIN
27
28@class OFMutableArray OF_GENERIC(ObjectType);
29@class OFDate;
30#ifdef OF_HAVE_THREADS
31@class OFMutex;
32#endif
33@class OFMutableData;
34
42@protocol OFKernelEventObserverDelegate <OFObject>
43@optional
58- (void)objectIsReadyForReading: (id)object;
59
65- (void)objectIsReadyForWriting: (id)object;
66
67#if defined(OF_AMIGAOS) || defined(DOXYGEN)
73- (void)execSignalWasReceived: (ULONG)signalMask;
74#endif
75@end
76
84@protocol OFReadyForReadingObserving <OFObject>
89@property (readonly, nonatomic) int fileDescriptorForReading;
90@end
91
99@protocol OFReadyForWritingObserving <OFObject>
104@property (readonly, nonatomic) int fileDescriptorForWriting;
105@end
106
107#ifdef OF_HAVE_SOCKETS
118{
119 OFMutableArray OF_GENERIC(id <OFReadyForReadingObserving>)
120 *_readObjects;
121 OFMutableArray OF_GENERIC(id <OFReadyForWritingObserving>)
122 *_writeObjects;
123 id <OFKernelEventObserverDelegate> _Nullable _delegate;
124# if defined(OF_AMIGAOS)
125 struct Task *_waitingTask;
126 ULONG _cancelSignal;
127# elif defined(OF_HAVE_PIPE)
128 int _cancelFD[2];
129# else
130 OFSocketHandle _cancelFD[2];
131 struct sockaddr_in _cancelAddr;
132# endif
133# ifdef OF_AMIGAOS
134 ULONG _execSignalMask;
135# endif
136 OF_RESERVE_IVARS(OFKernelEventObserver, 4)
137}
138
142@property OF_NULLABLE_PROPERTY (assign, nonatomic)
143 id <OFKernelEventObserverDelegate> delegate;
144
145# if defined(OF_AMIGAOS) || defined(DOXYGEN)
151@property (nonatomic) ULONG execSignalMask;
152# endif
153
159+ (instancetype)observer;
160
174- (void)addObjectForReading: (id <OFReadyForReadingObserving>)object;
175
186- (void)addObjectForWriting: (id <OFReadyForWritingObserving>)object;
187
198- (void)removeObjectForReading: (id <OFReadyForReadingObserving>)object;
199
210- (void)removeObjectForWriting: (id <OFReadyForWritingObserving>)object;
211
218- (void)observe;
219
228- (void)observeForTimeInterval: (OFTimeInterval)timeInterval;
229
238- (void)observeUntilDate: (OFDate *)date;
239
246- (void)cancel;
247
253- (bool)of_processReadBuffers;
254@end
255#endif
256
257OF_ASSUME_NONNULL_END
double OFTimeInterval
A time interval in seconds.
Definition OFObject.h:150
A class for storing, accessing and comparing dates.
Definition OFDate.h:30
A class that can observe multiple kernel events (e.g. streams being ready to read) at once.
Definition OFKernelEventObserver.h:118
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:26
A class for creating mutual exclusions.
Definition OFMutex.h:34
The root class for all other classes inside ObjFW.
Definition OFObject.h:688