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 | * The coordinator monitors and synchronizes all bilateral negotiation threads
|
---|
11 | * of each negotiator agent with an opponent regarding the whole preference list of the user.
|
---|
12 | */
|
---|
13 | public class Coordinator implements Runnable
|
---|
14 | {
|
---|
15 | // Messaging comin gin and out of the coordinator
|
---|
16 | protected BlockingQueue<NegotiationStatusMessage> cin;
|
---|
17 | protected BlockingQueue<CoordinationMessage> cout;
|
---|
18 |
|
---|
19 | public Coordinator(BlockingQueue<NegotiationStatusMessage> negotiationMsg,
|
---|
20 | BlockingQueue<CoordinationMessage> coordinationMsg)
|
---|
21 | {
|
---|
22 | cin = negotiationMsg;
|
---|
23 | cout = coordinationMsg;
|
---|
24 | }
|
---|
25 |
|
---|
26 | @Override
|
---|
27 | public void run()
|
---|
28 | {
|
---|
29 | // Send a very simple coordination message to Bob
|
---|
30 | try {
|
---|
31 | CoordinationMessage coordinationMessage = new CoordinationMessage();
|
---|
32 | coordinationMessage.f = new UF_IWant3Red();
|
---|
33 | cout.put(coordinationMessage);
|
---|
34 |
|
---|
35 | Thread.sleep(2000);
|
---|
36 |
|
---|
37 | CoordinationMessage coordinationMessage2 = new CoordinationMessage();
|
---|
38 | coordinationMessage2.f = new UF_IWantColorAndQuantity("Green", 7);
|
---|
39 | cout.put(coordinationMessage2);
|
---|
40 |
|
---|
41 | } catch (InterruptedException e) {
|
---|
42 | e.printStackTrace();
|
---|
43 | }
|
---|
44 |
|
---|
45 | }
|
---|
46 |
|
---|
47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.