]> git.ipfire.org Git - thirdparty/squid.git/blame - src/Pipeline.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / Pipeline.h
CommitLineData
8e64903f 1/*
4ac4a490 2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
8e64903f
AJ
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"
8d664cb0 13#include "http/forward.h"
8e64903f
AJ
14
15#include <list>
16
8e64903f 17/**
1fad8490 18 * A queue of transactions awaiting completion.
8e64903f 19 *
1fad8490 20 * Transactions in the queue may be fully processed, but not yet delivered,
8e64903f
AJ
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.
1fad8490
AJ
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.
8e64903f 29 *
1fad8490 30 * - HTTP/2 multiplexed streams can be processed and delivered in any order.
8e64903f
AJ
31 *
32 * For consistency we treat the pipeline as a FIFO queue in both cases.
33 */
34class Pipeline
35{
36 Pipeline(const Pipeline &) = delete;
37 Pipeline & operator =(const Pipeline &) = delete;
38
39public:
2c391676 40 Pipeline() : nrequests(0) {}
8ced7106 41 ~Pipeline() = default;
8e64903f
AJ
42
43 /// register a new request context to the pipeline
d3dddfb5 44 void add(const Http::StreamPointer &);
8e64903f
AJ
45
46 /// get the first request context in the pipeline
d3dddfb5 47 Http::StreamPointer front() const;
8e64903f 48
da6dbcd1
EB
49 /// get the last request context in the pipeline
50 Http::StreamPointer back() const;
51
8e64903f 52 /// how many requests are currently pipelined
2c391676 53 size_t count() const {return requests.size();}
8e64903f
AJ
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
2c391676 61 /// deregister the front request from the pipeline
d3dddfb5 62 void popMe(const Http::StreamPointer &);
8e64903f
AJ
63
64 /// Number of requests seen in this pipeline (so far).
65 /// Includes incomplete transactions.
66 uint32_t nrequests;
67
68private:
69 /// requests parsed from the connection but not yet completed.
d3dddfb5 70 std::list<Http::StreamPointer> requests;
8e64903f
AJ
71};
72
73#endif /* SQUID_SRC_PIPELINE_H */
74