2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_SRC_PIPELINE_H
10 #define SQUID_SRC_PIPELINE_H
12 #include "base/RefCount.h"
16 class ClientSocketContext
;
17 typedef RefCount
<ClientSocketContext
> ClientSocketContextPointer
;
20 * A queue of transactions awaiting completion.
22 * Transactions in the queue may be fully processed, but not yet delivered,
23 * or only partially processed.
25 * - HTTP/1 pipelined requests can be processed out of order but
26 * responses MUST be written to the client in-order.
27 * The front() context is for the response writing transaction.
28 * The back context may still be reading a request payload/body.
29 * Other contexts are in deferred I/O state, but may be accumulating
30 * payload/body data to be written later.
32 * - HTTP/2 multiplexed streams can be processed and delivered in any order.
34 * For consistency we treat the pipeline as a FIFO queue in both cases.
38 Pipeline(const Pipeline
&) = delete;
39 Pipeline
& operator =(const Pipeline
&) = delete;
42 Pipeline() : nrequests(0) {}
43 ~Pipeline() = default;
45 /// register a new request context to the pipeline
46 void add(const ClientSocketContextPointer
&);
48 /// get the first request context in the pipeline
49 ClientSocketContextPointer
front() const;
51 /// how many requests are currently pipelined
52 size_t count() const {return requests
.size();}
54 /// whether there are none or any requests currently pipelined
55 bool empty() const {return requests
.empty();}
57 /// tell everybody about the err, and abort all waiting requests
58 void terminateAll(const int xerrno
);
60 /// deregister the front request from the pipeline
61 void popMe(const ClientSocketContextPointer
&);
63 /// Number of requests seen in this pipeline (so far).
64 /// Includes incomplete transactions.
68 /// requests parsed from the connection but not yet completed.
69 std::list
<ClientSocketContextPointer
> requests
;
72 #endif /* SQUID_SRC_PIPELINE_H */