]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/RequestId.h
2 * Copyright (C) 1996-2023 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_IPC_REQUESTID_H
10 #define SQUID_SRC_IPC_REQUESTID_H
12 #include "ipc/forward.h"
13 #include "ipc/QuestionerId.h"
20 /// uniquely identifies an IPC request among same-type concurrent IPC requests
21 /// submitted by a single Squid instance
25 /// A simple ID for correlating IPC responses with pending requests.
26 /// Value 0 has a special meaning of "unset/unknown", but otherwise opaque.
27 typedef unsigned int Index
;
29 /// Request sender's constructor.
30 /// For performance and clarity sake, default constructor is preferred to 0 index.
31 explicit RequestId(Index
);
33 /// request recipient's constructor
34 RequestId() = default;
36 /// Make the ID unset/unknown.
37 /// Optimization: leaves the questioner field alone.
38 void reset() { index_
= 0; }
40 /// Make the ID set/known with the given (by the questioner) index.
41 /// For performance and clarity sake, reset(void) is preferred to reset(0).
42 void reset(const Index anIndex
) { *this = RequestId(anIndex
); }
44 QuestionerId
questioner() const { return qid_
; }
45 Index
index() const { return index_
; }
47 // these conversion operators allow our users to treat us as an Index
48 operator Index() const { return index_
; }
49 RequestId
&operator =(const Index anIndex
) { anIndex
? reset(anIndex
) : reset(); return *this; }
52 /// the sender of the request
55 /// request ID; unique within pending same-qid_ questions of the same kind
59 std::ostream
&operator <<(std::ostream
&, const RequestId
&);
63 #endif /* SQUID_SRC_IPC_REQUESTID_H */