QuestionerId.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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_IPC_QUESTIONERID_H
10#define SQUID_SRC_IPC_QUESTIONERID_H
11
12#include "ipc/forward.h"
13
14#include <iosfwd>
15
16namespace Ipc
17{
18
22{
23public:
25 QuestionerId() = default;
26
28 void pack(TypedMsgHdr &) const;
29
31 void unpack(const TypedMsgHdr &);
32
34 void rejectAnswerIfStale() const;
35
37 void print(std::ostream &) const;
38
39private:
41 explicit QuestionerId(const pid_t aPid): pid(aPid) {}
43
46 pid_t pid = -1;
47};
48
51
54template <class Answer>
55const Answer &
56Mine(const Answer &answer)
57{
58 answer.intendedRecepient().rejectAnswerIfStale();
59 return answer;
60}
61
62inline std::ostream &
63operator <<(std::ostream &os, const QuestionerId &qid)
64{
65 qid.print(os);
66 return os;
67}
68
69} // namespace Ipc;
70
71#endif /* SQUID_SRC_IPC_QUESTIONERID_H */
72
friend QuestionerId MyQuestionerId()
the questioner ID of the current/calling process
void pack(TypedMsgHdr &) const
for sending the ID of the asking process
Definition: QuestionerId.cc:25
void print(std::ostream &) const
reports the stored opaque ID value (for debugging)
Definition: QuestionerId.cc:47
void unpack(const TypedMsgHdr &)
for receiving the ID of the asking process
Definition: QuestionerId.cc:31
void rejectAnswerIfStale() const
does nothing but throws if the questioner was not the current process
Definition: QuestionerId.cc:37
QuestionerId(const pid_t aPid)
for MyQuestionerId() convenience
Definition: QuestionerId.h:41
QuestionerId()=default
to-be-determined ID
struct msghdr with a known type, fixed-size I/O and control buffers
Definition: TypedMsgHdr.h:35
Definition: IpcIoFile.h:24
const Answer & Mine(const Answer &answer)
Definition: QuestionerId.h:56
std::ostream & operator<<(std::ostream &os, const QuestionerId &qid)
Definition: QuestionerId.h:63
QuestionerId MyQuestionerId()
the questioner ID of the current/calling process
Definition: QuestionerId.cc:18

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors