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 program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#import "OFObject.h"
21#ifdef OF_HAVE_SOCKETS
22# import "OFSocket.h"
23#endif
24
25#ifdef OF_AMIGAOS
26# include <exec/types.h>
27# include <exec/tasks.h>
28#endif
29
30OF_ASSUME_NONNULL_BEGIN
31
32@class OFMutableArray OF_GENERIC(ObjectType);
33@class OFDate;
34@class OFMutableData;
35
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
83@protocol OFReadyForReadingObserving <OFObject>
88@property (readonly, nonatomic) int fileDescriptorForReading;
89@end
90
97@protocol OFReadyForWritingObserving <OFObject>
102@property (readonly, nonatomic) int fileDescriptorForWriting;
103@end
104
105#ifdef OF_HAVE_SOCKETS
115{
116 OFMutableArray OF_GENERIC(id <OFReadyForReadingObserving>)
117 *_readObjects;
118 OFMutableArray OF_GENERIC(id <OFReadyForWritingObserving>)
119 *_writeObjects;
120 id <OFKernelEventObserverDelegate> _Nullable _delegate;
121# if defined(OF_AMIGAOS)
122 struct Task *_waitingTask;
123 ULONG _cancelSignal;
124# elif defined(OF_HAVE_PIPE)
125 int _cancelFD[2];
126# else
127 OFSocketHandle _cancelFD[2];
128 struct sockaddr_in _cancelAddr;
129# endif
130# ifdef OF_AMIGAOS
131 ULONG _execSignalMask;
132# endif
133 OF_RESERVE_IVARS(OFKernelEventObserver, 4)
134}
135
139@property OF_NULLABLE_PROPERTY (assign, nonatomic)
140 id <OFKernelEventObserverDelegate> delegate;
141
142# if defined(OF_AMIGAOS) || defined(DOXYGEN)
148@property (nonatomic) ULONG execSignalMask;
149# endif
150
156+ (instancetype)observer;
157
171- (void)addObjectForReading: (id <OFReadyForReadingObserving>)object;
172
183- (void)addObjectForWriting: (id <OFReadyForWritingObserving>)object;
184
195- (void)removeObjectForReading: (id <OFReadyForReadingObserving>)object;
196
207- (void)removeObjectForWriting: (id <OFReadyForWritingObserving>)object;
208
215- (void)observe;
216
225- (void)observeForTimeInterval: (OFTimeInterval)timeInterval;
226
235- (void)observeUntilDate: (OFDate *)date;
236
243- (void)cancel;
244
250- (bool)of_processReadBuffers;
251@end
252#endif
253
254OF_ASSUME_NONNULL_END
double OFTimeInterval
A time interval in seconds.
Definition OFObject.h:154
A class for storing, accessing and comparing dates.
Definition OFDate.h:34
A class that can observe multiple kernel events (e.g. streams being ready to read) at once.
Definition OFKernelEventObserver.h:115
An abstract class for storing, adding and removing objects in an array.
Definition OFMutableArray.h:48
A class for storing and manipulating arbitrary data in an array.
Definition OFMutableData.h:30
The root class for all other classes inside ObjFW.
Definition OFObject.h:692