AsyncCallQueue.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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.h"
15 
16 AsyncCallQueue *AsyncCallQueue::TheInstance = 0;
17 
19 {
20 }
21 
23 {
24  assert(call != NULL);
25  assert(!call->theNext);
26  if (theHead != NULL) { // append
28  theTail->theNext = call;
29  theTail = call;
30  } else { // create queue from cratch
31  theHead = theTail = call;
32  }
33 }
34 
35 // Fire all scheduled calls; returns true if at least one call was fired.
36 // The calls may be added while the current call is in progress.
37 bool
39 {
40  const bool made = theHead != NULL;
41  while (theHead != NULL)
42  fireNext();
43  return made;
44 }
45 
46 void
48 {
50  theHead = call->theNext;
51  call->theNext = NULL;
52  if (theTail == call)
53  theTail = NULL;
54 
55  debugs(call->debugSection, call->debugLevel, "entering " << *call);
56  call->make();
57  debugs(call->debugSection, call->debugLevel, "leaving " << *call);
58 }
59 
62 {
63  // TODO: how to remove this frequent check while supporting early calls?
64  if (!TheInstance)
66 
67  return *TheInstance;
68 }
69 
AsyncCall::Pointer theHead
#define assert(EX)
Definition: assert.h:17
void make()
Definition: AsyncCall.cc:35
const int debugSection
Definition: AsyncCall.h:77
const int debugLevel
Definition: AsyncCall.h:78
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
AsyncCall::Pointer theTail
AsyncCall::Pointer theNext
Definition: AsyncCall.h:86
static AsyncCallQueue * TheInstance
void schedule(AsyncCall::Pointer &call)
#define NULL
Definition: types.h:166
static AsyncCallQueue & Instance()

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors