-
Notifications
You must be signed in to change notification settings - Fork 638
Expand file tree
/
Copy pathAsyncCallList.cc
More file actions
48 lines (43 loc) · 1.06 KB
/
AsyncCallList.cc
File metadata and controls
48 lines (43 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Copyright (C) 1996-2026 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
* Please see the COPYING and CONTRIBUTORS files for details.
*/
#include "squid.h"
#include "base/Assure.h"
#include "base/AsyncCall.h"
#include "base/AsyncCallList.h"
void
AsyncCallList::add(const AsyncCall::Pointer &call)
{
Assure(call);
Assure(!call->Next());
if (tail) { // append to the existing list
Assure(head);
Assure(!tail->Next());
tail->setNext(call);
tail = call;
} else { // create a list from scratch
Assure(!head);
head = tail = call;
}
++length;
Assure(length); // no overflows
}
AsyncCall::Pointer
AsyncCallList::extract()
{
if (!head)
return AsyncCallPointer();
Assure(tail);
Assure(length);
const auto call = head;
head = call->Next();
call->setNext(nullptr);
if (tail == call)
tail = nullptr;
--length;
return call;
}