-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessage.cpp
94 lines (71 loc) · 1.4 KB
/
Message.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "std.h"
#include "rope.h"
#include "Message.h"
#include "Loggers.h"
#include "RopeVM.h"
using namespace std;
int msg_count = 0; // just for debug
Message::Message(MsgType type, SpmtThread* target_st)
:
m_type(type),
m_target_st(target_st),
m_effect(nullptr)
{
}
Message::~Message()
{
}
MsgType
Message::get_type()
{
return m_type;
}
SpmtThread*
Message::get_target_st()
{
return m_target_st;
}
Effect*
Message::get_effect()
{
return m_effect;
}
void
Message::set_effect(Effect* effect)
{
m_effect = effect;
}
bool
Message::equal(Message* msg)
{
assert(false); // 异步消息比较指针,所以其equal没有实现。
return false;
}
ostream&
operator<<(ostream& os, const Message* msg)
{
msg->show(os);
if (p) {
os << " (msg: " << (void*)msg << ")";
}
return os;
}
void
show_msg_detail(ostream& os, int id, Message* msg)
{
msg->show_detail(os, id);
}
bool
g_is_async_msg(Message* msg)
{
MsgType type = msg->get_type();
if (RopeVM::support_self_read and (type == MsgType::GET || type == MsgType::ALOAD)) // 若支持自行get,get和aload都不算是异步消息。
return false;
if (type == MsgType::INVOKE
or type == MsgType::PUT
or type == MsgType::GET
or type == MsgType::ASTORE
or type == MsgType::ALOAD)
return true;
return false;
}