AsyncCallList.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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#include "squid.h"
10#include "base/Assure.h"
11#include "base/AsyncCall.h"
12#include "base/AsyncCallList.h"
13
14void
16{
17 Assure(call);
18 Assure(!call->Next());
19 if (tail) { // append to the existing list
20 Assure(head);
21 Assure(!tail->Next());
22 tail->setNext(call);
23 tail = call;
24 } else { // create a list from scratch
25 Assure(!head);
26 head = tail = call;
27 }
28 ++length;
29 Assure(length); // no overflows
30}
31
34{
35 if (!head)
36 return AsyncCallPointer();
37
38 Assure(tail);
40 const auto call = head;
41 head = call->Next();
42 call->setNext(nullptr);
43 if (tail == call)
44 tail = nullptr;
45 --length;
46 return call;
47}
48
#define Assure(condition)
Definition: Assure.h:35
RefCount< AsyncCall > AsyncCallPointer
Definition: forward.h:30
AsyncCallPointer tail
the latest still-stored call (or nil)
Definition: AsyncCallList.h:38
AsyncCallPointer extract()
size_t length
the number of currently stored calls
Definition: AsyncCallList.h:39
AsyncCallPointer head
the earliest still-stored call (or nil)
Definition: AsyncCallList.h:37
void add(const AsyncCallPointer &)
stores the given async call
AsyncCall::Pointer & Next()
Definition: AsyncCall.h:66
void setNext(AsyncCall::Pointer aNext)
Definition: AsyncCall.h:62

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors