-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwatcardoffice.h
73 lines (59 loc) · 1.7 KB
/
watcardoffice.h
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
#ifndef __WATCARDOFFICE_H__
#define __WATCARDOFFICE_H__
#include "watcard.h"
#include "MPRNG.h"
//#include "bank.h"
//#include "printer.h"
#include <vector>
//class WATCard;
_Monitor Bank;
_Monitor Printer;
_Task WATCardOffice {
_Task Courier;
//store info in Job
struct Args{
unsigned int sid;
unsigned int myamount;
WATCard* mycard;
Bank& mybank;
//constructor
Args(unsigned int sid,unsigned int myamount, WATCard* mycard,Bank& mybank)
:sid(sid),myamount(myamount),mycard(mycard),mybank(mybank)
{}
};
struct Job { // marshalled arguments and return future
Args args; // call arguments (YOU DEFINE "Args")
WATCard::FWATCard result; // return future
//consturctor
Job( Args args )
:args( args )
{}
};
_Task Courier {
unsigned int id;
WATCardOffice *myoffice;
Printer& prt;
void main();
public:
Courier(unsigned int id,WATCardOffice* myoffice,Printer& prt)
:id(id),myoffice(myoffice),prt(prt)
{}
}; // communicates with bank
//pass in
Printer& prt;
Bank& bank;
unsigned int numCouriers;
std::vector<Job*>requests;//server request vector
bool deleteflag;//use to sync when destruct
Courier** courierPool;
//uCondition waitChan;//let request queue up at here
void main();
public:
_Event Lost {}; // lost WATCard
WATCardOffice( Printer &prt, Bank &bank, unsigned int numCouriers );
~WATCardOffice();
WATCard::FWATCard create( unsigned int sid, unsigned int amount );
WATCard::FWATCard transfer( unsigned int sid, unsigned int amount, WATCard *card );
Job* requestWork();
};
#endif