blob: 8b81ce428e2faee280cb28ad752d29c84dfe5eb0 (
plain)
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
|
#include "cctk.h"
#include "cctk_Parameters.h"
#include "commstate.hh"
// Communication state control
comm_state::comm_state ()
: thestate(state_recv)
{
}
void comm_state::step ()
{
DECLARE_CCTK_PARAMETERS;
assert (thestate!=state_done);
if (combine_recv_send) {
switch (thestate) {
case state_recv:
assert (tmps1.empty());
thestate = state_wait;
break;
case state_send:
assert (0);
case state_wait:
assert (tmps1.empty());
assert (tmps2.empty());
thestate = state_done;
break;
case state_done:
assert (0);
default:
assert (0);
}
} else {
switch (thestate) {
case state_recv:
assert (tmps2.empty());
thestate = state_send;
break;
case state_send:
assert (tmps1.empty());
thestate = state_wait;
break;
case state_wait:
assert (tmps1.empty());
assert (tmps2.empty());
thestate = state_done;
break;
case state_done:
assert (0);
default:
assert (0);
}
}
}
bool comm_state::done ()
{
return thestate==state_done;
}
comm_state::~comm_state ()
{
assert (thestate==state_recv || thestate==state_done);
assert (tmps1.empty());
assert (tmps2.empty());
assert (requests.empty());
}
|