]>
Commit | Line | Data |
---|---|---|
8ff3fa2e | 1 | /* |
bbc27441 | 2 | * Copyright (C) 1996-2014 The Squid Software Foundation and contributors |
8ff3fa2e | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
8ff3fa2e | 7 | */ |
8 | ||
9 | #ifndef SQUID_ASYNCENGINE_H | |
10 | #define SQUID_ASYNCENGINE_H | |
11 | ||
8ff3fa2e | 12 | /* Abstract interface for async engines which an event loop can utilise. |
13 | * | |
14 | * Some implementations will be truely async, others like the event engine | |
15 | * will be pseudo async. | |
16 | */ | |
17 | ||
18 | class AsyncEngine | |
19 | { | |
20 | ||
21 | public: | |
22 | /* error codes returned from checkEvents. If the return value is not | |
23 | * negative, then it is the requested delay until the next call. If it is | |
24 | * negative, it is one of the following codes: | |
25 | */ | |
26 | enum CheckError { | |
27 | /* this engine is completely idle: it has no pending events, and nothing | |
28 | * registered with it that can create events | |
29 | */ | |
30 | EVENT_IDLE = -1, | |
31 | /* some error has occured in this engine */ | |
ffb809be | 32 | EVENT_ERROR = -2 |
8ff3fa2e | 33 | }; |
34 | ||
35 | virtual ~AsyncEngine() {} | |
36 | ||
37 | /* Check the engine for events. If there are events that have completed, | |
38 | * the engine should at this point hand them off to their dispatcher. | |
26ac0430 | 39 | * Engines that operate asynchronously - i.e. the DiskThreads engine - |
8ff3fa2e | 40 | * should hand events off to their dispatcher as they arrive rather than |
41 | * waiting for checkEvents to be called. Engines like poll and select should | |
42 | * use this call as the time to perform their checks with the OS for new | |
43 | * events. | |
44 | * | |
45 | * The return value is the status code of the event checking. If its a | |
46 | * non-negative value then it is used as hint for the minimum requested | |
47 | * time before checkEvents is called again. I.e. the event engine knows | |
26ac0430 | 48 | * how long it is until the next event will be scheduled - so it will |
8ff3fa2e | 49 | * return that time (in milliseconds). |
50 | * | |
51 | * The timeout value is a requested timeout for this engine - the engine | |
52 | * should not block for more than this period. (If it takes longer than the | |
53 | * timeout to do actual checks thats fine though undesirable). | |
54 | */ | |
55 | virtual int checkEvents(int timeout) = 0; | |
56 | }; | |
57 | ||
58 | #endif /* SQUID_ASYNCENGINE_H */ | |
f53969cc | 59 |