Line | |
---|
1 | package onetomany.bargainingchipsgame.players;
|
---|
2 |
|
---|
3 | import java.util.concurrent.BlockingQueue;
|
---|
4 |
|
---|
5 | import onetomany.bargainingchipsgame.players.utilityfunction.UF_IWant3Red;
|
---|
6 | import onetomany.bargainingchipsgame.players.utilityfunction.UF_IWantColorAndQuantity;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Coordinates all bilateral threads.
|
---|
10 | */
|
---|
11 | public class Coordinator implements Runnable
|
---|
12 | {
|
---|
13 | // Messaging comin gin and out of the coordinator
|
---|
14 | protected BlockingQueue<NegotiationStatusMessage> cin;
|
---|
15 | protected BlockingQueue<CoordinationMessage> cout;
|
---|
16 |
|
---|
17 | public Coordinator(BlockingQueue<NegotiationStatusMessage> negotiationMsg,
|
---|
18 | BlockingQueue<CoordinationMessage> coordinationMsg)
|
---|
19 | {
|
---|
20 | cin = negotiationMsg;
|
---|
21 | cout = coordinationMsg;
|
---|
22 | }
|
---|
23 |
|
---|
24 | @Override
|
---|
25 | public void run()
|
---|
26 | {
|
---|
27 | // Send a very simple coordination message to Bob
|
---|
28 | try {
|
---|
29 | CoordinationMessage coordinationMessage = new CoordinationMessage();
|
---|
30 | coordinationMessage.f = new UF_IWant3Red();
|
---|
31 | cout.put(coordinationMessage);
|
---|
32 |
|
---|
33 | Thread.sleep(2000);
|
---|
34 |
|
---|
35 | CoordinationMessage coordinationMessage2 = new CoordinationMessage();
|
---|
36 | coordinationMessage2.f = new UF_IWantColorAndQuantity("Green", 7);
|
---|
37 | cout.put(coordinationMessage2);
|
---|
38 |
|
---|
39 | } catch (InterruptedException e) {
|
---|
40 | e.printStackTrace();
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|
44 |
|
---|
45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.