-
Notifications
You must be signed in to change notification settings - Fork 1
/
BroadcastClient.C
43 lines (37 loc) · 994 Bytes
/
BroadcastClient.C
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
/**
*** Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by
*** The Board of Trustees of the University of Illinois.
*** All rights reserved.
**/
#include "InfoStream.h"
#include "charm++.h"
#include "BroadcastMgr.h"
#include "BroadcastClient.h"
#define MIN_DEBUG_LEVEL 3
// #define DEBUGM
#include "Debug.h"
BroadcastClient::BroadcastClient(int id) {
this->id = id;
BroadcastMgr::Object()->subscribe(*this);
waitForTag = -1;
suspended = 0;
}
BroadcastClient::~BroadcastClient() {
BroadcastMgr::Object()->unsubscribe(*this);
}
void
BroadcastClient::awaken(int theid, int tag) {
DebugM(1, "awaken() client id = " << id << " tag = " << tag << "\n");
if (suspended && theid == this->id && tag == waitForTag) {
CthAwaken(thread);
suspended = 0; waitForTag = -1;
}
}
void
BroadcastClient::suspendFor(int tag) {
DebugM(1, "suspending() client id = " << id << " tag = " << tag << "\n");
suspended = 1;
waitForTag = tag;
thread = CthSelf();
CthSuspend();
}