]> git.ipfire.org Git - thirdparty/squid.git/blame - src/AsyncEngine.h
Maintenance: automate header guards 2/3 (#1655)
[thirdparty/squid.git] / src / AsyncEngine.h
CommitLineData
8ff3fa2e 1/*
b8ae064d 2 * Copyright (C) 1996-2023 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
ff9d9458
FC
9#ifndef SQUID_SRC_ASYNCENGINE_H
10#define SQUID_SRC_ASYNCENGINE_H
8ff3fa2e 11
8ff3fa2e 12/* Abstract interface for async engines which an event loop can utilise.
13 *
2f8abb64 14 * Some implementations will be truly async, others like the event engine
8ff3fa2e 15 * will be pseudo async.
16 */
17
18class AsyncEngine
19{
20
21public:
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,
61beade2 31 /* some error has occurred 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
2f8abb64 53 * timeout to do actual checks that's fine though undesirable).
8ff3fa2e 54 */
55 virtual int checkEvents(int timeout) = 0;
56};
57
ff9d9458 58#endif /* SQUID_SRC_ASYNCENGINE_H */
f53969cc 59