YAMI4 C++
outgoing_message_info.h
1 // Copyright Maciej Sobczak 2008-2019.
2 // This file is part of YAMI4.
3 //
4 // YAMI4 is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // YAMI4 is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with YAMI4. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef YAMICPP_OUTGOING_MESSAGE_INFO_H_INCLUDED
18 #define YAMICPP_OUTGOING_MESSAGE_INFO_H_INCLUDED
19 
20 #include "message_state.h"
21 #include "parameters.h"
22 #include <cstddef>
23 #include <vector>
24 
25 // selected per platform
26 #include <mutex.h>
27 #include <semaphore.h>
28 #include <flag.h>
29 
30 namespace yami
31 {
32 
33 class outgoing_message;
34 
35 namespace details
36 {
37 
38 class agent_impl;
39 class outgoing_message_dispatcher_base;
40 
41 struct outgoing_message_info
42 {
43  message_state state;
44  long long message_id;
45  std::size_t sent_bytes;
46  std::size_t total_byte_count;
47  parameters * reply_body;
48  std::vector<char> * reply_raw_buffer;
49  std::string exception_msg;
50 
51  mutex mtx;
52  mutable flag transmitted;
53  mutable flag completed;
54 
55  agent_impl * agent;
56 
57  // for callback (if used), owned by this info object
58  outgoing_message * out_msg;
59  outgoing_message_dispatcher_base * message_callback;
60  bool callback_pending;
61 
62  // this is always called with mtx locked,
63  // possibly with some outer_mtx locked as well
64  void process_callback(mutex * outer_mtx = NULL);
65 
66  std::size_t ref_count;
67 
68  void dec_ref_count(bool disown_callback = false);
69 };
70 
71 } // namespace details
72 
73 } // namespace yami
74 
75 #endif // YAMICPP_OUTGOING_MESSAGE_INFO_H_INCLUDED
message_state
Outgoing message state.
Definition: message_state.h:24
Namespace devoted to everything related to YAMI4.
Definition: activity_statistics_monitor.cpp:27
Message was fully transmitted.
Definition: message_state.h:27