]>
Commit | Line | Data |
---|---|---|
8ff3fa2e | 1 | |
2 | /* | |
8ff3fa2e | 3 | * |
4 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
5 | * ---------------------------------------------------------- | |
6 | * | |
7 | * Squid is the result of efforts by numerous individuals from | |
8 | * the Internet community; see the CONTRIBUTORS file for full | |
9 | * details. Many organizations have provided support for Squid's | |
10 | * development; see the SPONSORS file for full details. Squid is | |
11 | * Copyrighted (C) 2001 by the Regents of the University of | |
12 | * California; see the COPYRIGHT file for full details. Squid | |
13 | * incorporates software developed and/or copyrighted by other | |
14 | * sources; see the CREDITS file for full details. | |
15 | * | |
16 | * This program is free software; you can redistribute it and/or modify | |
17 | * it under the terms of the GNU General Public License as published by | |
18 | * the Free Software Foundation; either version 2 of the License, or | |
19 | * (at your option) any later version. | |
26ac0430 | 20 | * |
8ff3fa2e | 21 | * This program is distributed in the hope that it will be useful, |
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 | * GNU General Public License for more details. | |
26ac0430 | 25 | * |
8ff3fa2e | 26 | * You should have received a copy of the GNU General Public License |
27 | * along with this program; if not, write to the Free Software | |
28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
29 | * | |
30 | */ | |
31 | ||
32 | #ifndef SQUID_ASYNCENGINE_H | |
33 | #define SQUID_ASYNCENGINE_H | |
34 | ||
8ff3fa2e | 35 | /* Abstract interface for async engines which an event loop can utilise. |
36 | * | |
37 | * Some implementations will be truely async, others like the event engine | |
38 | * will be pseudo async. | |
39 | */ | |
40 | ||
41 | class AsyncEngine | |
42 | { | |
43 | ||
44 | public: | |
45 | /* error codes returned from checkEvents. If the return value is not | |
46 | * negative, then it is the requested delay until the next call. If it is | |
47 | * negative, it is one of the following codes: | |
48 | */ | |
49 | enum CheckError { | |
50 | /* this engine is completely idle: it has no pending events, and nothing | |
51 | * registered with it that can create events | |
52 | */ | |
53 | EVENT_IDLE = -1, | |
54 | /* some error has occured in this engine */ | |
ffb809be | 55 | EVENT_ERROR = -2 |
8ff3fa2e | 56 | }; |
57 | ||
58 | virtual ~AsyncEngine() {} | |
59 | ||
60 | /* Check the engine for events. If there are events that have completed, | |
61 | * the engine should at this point hand them off to their dispatcher. | |
26ac0430 | 62 | * Engines that operate asynchronously - i.e. the DiskThreads engine - |
8ff3fa2e | 63 | * should hand events off to their dispatcher as they arrive rather than |
64 | * waiting for checkEvents to be called. Engines like poll and select should | |
65 | * use this call as the time to perform their checks with the OS for new | |
66 | * events. | |
67 | * | |
68 | * The return value is the status code of the event checking. If its a | |
69 | * non-negative value then it is used as hint for the minimum requested | |
70 | * time before checkEvents is called again. I.e. the event engine knows | |
26ac0430 | 71 | * how long it is until the next event will be scheduled - so it will |
8ff3fa2e | 72 | * return that time (in milliseconds). |
73 | * | |
74 | * The timeout value is a requested timeout for this engine - the engine | |
75 | * should not block for more than this period. (If it takes longer than the | |
76 | * timeout to do actual checks thats fine though undesirable). | |
77 | */ | |
78 | virtual int checkEvents(int timeout) = 0; | |
79 | }; | |
80 | ||
81 | #endif /* SQUID_ASYNCENGINE_H */ |