25 #ifndef __I6ENGINE_CORE_MESSAGESTRUCT_H__
26 #define __I6ENGINE_CORE_MESSAGESTRUCT_H__
30 #include "boost/archive/text_iarchive.hpp"
31 #include "boost/archive/text_oarchive.hpp"
33 #ifdef ISIXE_WITH_PROFILING
34 #include "boost/date_time/posix_time/posix_time.hpp"
35 #include "boost/date_time/posix_time/time_serialize.hpp"
38 #include "boost/serialization/export.hpp"
39 #include "boost/serialization/list.hpp"
40 #include "boost/serialization/map.hpp"
41 #include "boost/serialization/vector.hpp"
43 #ifdef ISIXE_WITH_PROFILING
44 #include "boost/thread/mutex.hpp"
55 #ifdef ISIXE_WITH_PROFILING
56 std::vector<std::pair<std::string, boost::posix_time::ptime>> _timestamps;
57 mutable boost::mutex _lock;
60 template<
class Archive>
65 #ifdef ISIXE_WITH_PROFILING
66 boost::mutex::scoped_lock sl(_lock);
71 #ifdef ISIXE_WITH_PROFILING
75 MessageStruct() : _id(-1), _sender(), _waitForId(-1), _timestamps(), _lock() {
76 assert(_timestamps.size() == 0);
77 insertTimestamp(
"Create Default c'tor");
78 assert(_timestamps.size() == 1);
86 assert(_timestamps.size() == 0);
87 _timestamps = other._timestamps;
88 assert(_timestamps.size() == other._timestamps.size());
89 insertTimestamp(
"Copy");
90 assert(_timestamps.size() == other._timestamps.size() + 1);
100 MessageStruct(
const int64_t
id,
const IPKey & send = IPKey(),
const int64_t waitID = -1) : _id(id), _sender(send), _waitForId(waitID), _timestamps(), _lock() {
101 assert(_timestamps.size() == 0);
102 insertTimestamp(
"Create");
103 assert(_timestamps.size() == 1);
106 MessageStruct(int64_t
id, int64_t waitID) : _id(id), _sender(), _waitForId(waitID), _timestamps(), _lock() {}
125 MessageStruct(
const int64_t
id,
const IPKey & send,
const int64_t waitID) : _id(id), _sender(send), _waitForId(waitID) {
128 MessageStruct(int64_t
id, int64_t waitID) : _id(id), _sender(), _waitForId(waitID) {
144 #ifdef ISIXE_WITH_PROFILING
149 void insertTimestamp(
const std::string & text) {
151 size_t n = _timestamps.size();
152 boost::posix_time::ptime time = boost::posix_time::microsec_clock::universal_time();
153 _timestamps.push_back(std::make_pair(text, time));
155 assert(_timestamps.size() == n + 1);
163 std::string getTimestamps() {
164 std::stringstream ret;
165 ret <<
"\n\t\t" << _timestamps[0].first <<
"\n";
166 for (
size_t i = 1; i < _timestamps.size(); ++i) {
167 boost::posix_time::time_duration diff = boost::posix_time::time_period(_timestamps[i - 1].second, _timestamps[i].second).length();
168 if (diff.total_milliseconds() < 15) {
169 ret <<
"\t[\x1b[32m" << boost::posix_time::to_simple_string(diff) <<
"\x1b[0m]\n";
171 ret <<
"\t[\x1b[31m" << boost::posix_time::to_simple_string(diff) <<
"\x1b[0m]\n";
173 ret <<
"\t\t" << _timestamps[i].first <<
"\n";
MessageStruct(int64_t id, int64_t waitID)
void serialize(Archive &ar, const unsigned int)
MessageStruct(const int64_t id, const IPKey &send, const int64_t waitID)
Constructor for MessageStruct.
virtual ~MessageStruct()
Virtual destructor.
virtual MessageStruct * copy()
Copy method returning an exact copy of itself.
int64_t getID() const
returns the id
MessageStruct(const MessageStruct &other)
Copy constructor for MessageStruct.
int64_t getWaitID() const
returns the waitForId
MessageStruct()
Default constructor for MessageStruct.
struct ISIXE_CORE_API i6e::core::MessageStruct MessageStruct