-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatcardoffice.h
48 lines (44 loc) · 1.44 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
#pragma once
#include "watcard.h"
#include <queue>
class Printer;
class Bank;
_Task WATCardOffice {
struct Job { // marshalled arguments and return future
struct Args {
unsigned int sid;
unsigned int amount;
WATCard *card;
Args(unsigned int sid, unsigned int amount, WATCard *card=nullptr):
sid(sid), amount(amount), card(card) {}
};
Args args; // call arguments (YOU DEFINE "Args")
WATCard::FWATCard result; // return future
Job( Args args ) : args( args ) {}
};
_Task Courier {
WATCardOffice &office;
Bank &bank;
//jokay
Printer &prt;
//end jokay
unsigned int id;
void main();
public:
Courier(WATCardOffice &office, Bank &bank, Printer &prt, unsigned int id);
~Courier();
}; // communicates with bank
void main();
Printer &prt;
uCondition cond;
unsigned int numCouriers;
Courier **couriers;
std::queue<Job*> jobs;
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();
};