]> git.ipfire.org Git - thirdparty/squid.git/blob - src/Pipeline.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / Pipeline.h
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 #ifndef SQUID_SRC_PIPELINE_H
10 #define SQUID_SRC_PIPELINE_H
11
12 #include "base/RefCount.h"
13 #include "http/forward.h"
14
15 #include <list>
16
17 /**
18 * A queue of transactions awaiting completion.
19 *
20 * Transactions in the queue may be fully processed, but not yet delivered,
21 * or only partially processed.
22 *
23 * - HTTP/1 pipelined requests can be processed out of order but
24 * responses MUST be written to the client in-order.
25 * The front() context is for the response writing transaction.
26 * The back context may still be reading a request payload/body.
27 * Other contexts are in deferred I/O state, but may be accumulating
28 * payload/body data to be written later.
29 *
30 * - HTTP/2 multiplexed streams can be processed and delivered in any order.
31 *
32 * For consistency we treat the pipeline as a FIFO queue in both cases.
33 */
34 class Pipeline
35 {
36 Pipeline(const Pipeline &) = delete;
37 Pipeline & operator =(const Pipeline &) = delete;
38
39 public:
40 Pipeline() : nrequests(0) {}
41 ~Pipeline() = default;
42
43 /// register a new request context to the pipeline
44 void add(const Http::StreamPointer &);
45
46 /// get the first request context in the pipeline
47 Http::StreamPointer front() const;
48
49 /// get the last request context in the pipeline
50 Http::StreamPointer back() const;
51
52 /// how many requests are currently pipelined
53 size_t count() const {return requests.size();}
54
55 /// whether there are none or any requests currently pipelined
56 bool empty() const {return requests.empty();}
57
58 /// tell everybody about the err, and abort all waiting requests
59 void terminateAll(const int xerrno);
60
61 /// deregister the front request from the pipeline
62 void popMe(const Http::StreamPointer &);
63
64 /// Number of requests seen in this pipeline (so far).
65 /// Includes incomplete transactions.
66 uint32_t nrequests;
67
68 private:
69 /// requests parsed from the connection but not yet completed.
70 std::list<Http::StreamPointer> requests;
71 };
72
73 #endif /* SQUID_SRC_PIPELINE_H */
74