]> git.ipfire.org Git - thirdparty/squid.git/blame - src/base/AsyncCallQueue.cc
Maintenance: Removed most NULLs using modernize-use-nullptr (#1075)
[thirdparty/squid.git] / src / base / AsyncCallQueue.cc
CommitLineData
cfa20cf5 1/*
bf95c10a 2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
cfa20cf5 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.
cfa20cf5 7 */
8
bbc27441
AJ
9/* DEBUG: section 41 Event Processing */
10
f7f3304a 11#include "squid.h"
882255af 12#include "base/AsyncCall.h"
602d9612 13#include "base/AsyncCallQueue.h"
675b8408 14#include "debug/Stream.h"
cfa20cf5 15
aee3523a 16AsyncCallQueue *AsyncCallQueue::TheInstance = nullptr;
cfa20cf5 17
cfa20cf5 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{
a928fdfd
EB
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);
ccfbe8f4
AR
29 }
30 if (made)
31 CodeContext::Reset();
cfa20cf5 32 return made;
33}
34
cfa20cf5 35AsyncCallQueue &
36AsyncCallQueue::Instance()
37{
38 // TODO: how to remove this frequent check while supporting early calls?
26ac0430 39 if (!TheInstance)
cfa20cf5 40 TheInstance = new AsyncCallQueue();
41
42 return *TheInstance;
43}
44