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