ObjFW
OFRunLoop.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
3  * Jonathan Schleifer <js@webkeks.org>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #import "OFObject.h"
18 #ifdef OF_HAVE_SOCKETS
19 # import "OFTCPSocket.h"
20 #endif
21 
22 OF_ASSUME_NONNULL_BEGIN
23 
24 @class OFSortedList OF_GENERIC(ObjectType);
25 #ifdef OF_HAVE_THREADS
26 @class OFMutex;
27 @class OFCondition;
28 #endif
29 #ifdef OF_HAVE_SOCKETS
31 #endif
32 @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType);
33 @class OFTimer;
34 
40 @interface OFRunLoop: OFObject
41 {
42  OFSortedList *_timersQueue;
43 #ifdef OF_HAVE_THREADS
44  OFMutex *_timersQueueLock;
45 #endif
46 #if defined(OF_HAVE_SOCKETS)
47  OFKernelEventObserver *_kernelEventObserver;
48  OFMutableDictionary *_readQueues;
49 #elif defined(OF_HAVE_THREADS)
50  OFCondition *_condition;
51 #endif
52  volatile bool _running;
53 }
54 
60 + (OFRunLoop*)mainRunLoop;
61 
67 + (OFRunLoop*)currentRunLoop;
68 
74 - (void)addTimer: (OFTimer*)timer;
75 
79 - (void)run;
80 
85 - (void)stop;
86 @end
87 
88 OF_ASSUME_NONNULL_END
A class for creating mutual exclusions.
Definition: OFMutex.h:29
The root class for all other classes inside ObjFW.
Definition: OFObject.h:364
A class which provides easy to use sorted double-linked lists.
Definition: OFSortedList.h:35
A class for creating and firing timers.
Definition: OFTimer.h:44
An abstract class for storing and changing objects in a dictionary.
Definition: OFMutableDictionary.h:47
A class that can observe multiple kernel events (e.g. streams being ready to read) at once...
Definition: OFKernelEventObserver.h:111
A class providing a run loop for the application and its processes.
Definition: OFRunLoop.h:40
A class implementing a condition variable for thread synchronization.
Definition: OFCondition.h:28