]> git.ipfire.org Git - thirdparty/squid.git/blame_incremental - src/base/AsyncCallQueue.cc
Simplify appending SBuf to String (#2108)
[thirdparty/squid.git] / src / base / AsyncCallQueue.cc
... / ...
CommitLineData
1/*
2 * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9/* DEBUG: section 41 Event Processing */
10
11#include "squid.h"
12#include "base/AsyncCall.h"
13#include "base/AsyncCallQueue.h"
14#include "debug/Stream.h"
15
16AsyncCallQueue *AsyncCallQueue::TheInstance = nullptr;
17
18// Fire all scheduled calls; returns true if at least one call was fired.
19// The calls may be added while the current call is in progress.
20bool
21AsyncCallQueue::fire()
22{
23 const auto made = scheduled.size() > 0;
24 while (const auto call = scheduled.extract()) {
25 CodeContext::Reset(call->codeContext);
26 debugs(call->debugSection, call->debugLevel, "entering " << *call);
27 call->make();
28 debugs(call->debugSection, call->debugLevel, "leaving " << *call);
29 }
30 if (made)
31 CodeContext::Reset();
32 return made;
33}
34
35AsyncCallQueue &
36AsyncCallQueue::Instance()
37{
38 // TODO: how to remove this frequent check while supporting early calls?
39 if (!TheInstance)
40 TheInstance = new AsyncCallQueue();
41
42 return *TheInstance;
43}
44