Line | |
---|
1 | package onetomany.bargainingchipsgame.players;
|
---|
2 |
|
---|
3 | import java.util.concurrent.BlockingQueue;
|
---|
4 |
|
---|
5 | import onetomany.bargainingchipsgame.WishList;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * The coordinator monitors and synchronizes all bilateral negotiation threads.
|
---|
9 | */
|
---|
10 | public class Coordinator implements Runnable
|
---|
11 | {
|
---|
12 | // Messages coming in and out of the coordinator
|
---|
13 | protected BlockingQueue<StatusMessage> cin;
|
---|
14 | protected BlockingQueue<CoordinationMessage> cout;
|
---|
15 | /** The fixed, initial wish list that should be obtained overall */
|
---|
16 | private WishList overallWishList;
|
---|
17 |
|
---|
18 | public Coordinator(WishList wishlist, BlockingQueue<StatusMessage> negotiationMsg,
|
---|
19 | BlockingQueue<CoordinationMessage> coordinationMsg)
|
---|
20 | {
|
---|
21 | this.overallWishList = wishlist;
|
---|
22 | cin = negotiationMsg;
|
---|
23 | cout = coordinationMsg;
|
---|
24 | }
|
---|
25 |
|
---|
26 | @Override
|
---|
27 | public void run()
|
---|
28 | {
|
---|
29 | // Send a very simple coordination message to Bob_i after a while
|
---|
30 | try {
|
---|
31 | Thread.sleep(2000);
|
---|
32 |
|
---|
33 | // CoordinationMessage coordinationMessage2 = new CoordinationMessage();
|
---|
34 | // coordinationMessage2.f = new UF_IWantColorAndQuantity("Green", 7);
|
---|
35 | // cout.put(coordinationMessage2);
|
---|
36 |
|
---|
37 | } catch (InterruptedException e) {
|
---|
38 | e.printStackTrace();
|
---|
39 | }
|
---|
40 |
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.