-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequestQueue_manager.cpp
More file actions
71 lines (44 loc) · 1.71 KB
/
requestQueue_manager.cpp
File metadata and controls
71 lines (44 loc) · 1.71 KB
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 "node_controller.hpp"
#include "globals.hpp"
#include "message_buffer.hpp"
#include <iostream>
extern nodeController::Ricart_RequestQueue RQST_Q;
extern unsigned MY_NODE_ID;
void * nodeController::request_queue_manager( void* argument )
{
using namespace nodeController::requestQueue_manager;
using nodeController::Message;
using std::cerr;
using std::endl;
thread_arg arg = *(thread_arg *) argument;
//delete (thread_arg *) argument;
while ( true ) {
Message msg;
msg = arg.rqstQ_buffer->consume_msg( arg.whichrow );
switch ( msg.type ) {
case MESSAGE_T::REPLY:
if ( ( arg.whichrow % 2 ) == 0 ) {
std::cerr << "request_queue_manager:\n"
"whichrow arg should be odd for REPLY message" <<
std::endl << msg << std::endl;
exit( EXIT_FAILURE );
}
RQST_Q.remove_finished_peers( msg.act, msg.sub_act, msg );
break;
case MESSAGE_T::REQUEST:
if ( ( arg.whichrow % 2 ) != 0 ) {
std::cerr << "request_queue_manager:\n"
"whichrow should be even for REQUEST message" <<
std::endl << msg << std::endl;
exit( EXIT_FAILURE );
}
RQST_Q.enqueue_request( msg.act, msg.sub_act, msg );
break;
default:
cerr << "request_queue_manager:\n received msg with invalid "
"MESSAGE_T type\n" << msg << endl;
exit( EXIT_FAILURE );
}
}
return nullptr;
}