source: src/main/java/onetomany/bargainingchipsgame/players/Coordinator.java@ 281

Last change on this file since 281 was 280, checked in by Tim Baarslag, 5 years ago

CoordinationMessages are concurrent

File size: 1.2 KB
Line 
1package onetomany.bargainingchipsgame.players;
2
3import java.util.concurrent.BlockingQueue;
4
5import onetomany.bargainingchipsgame.players.utilityfunction.UF_IWant3Red;
6import onetomany.bargainingchipsgame.players.utilityfunction.UF_IWantColorAndQuantity;
7
8/**
9 * Coordinates all bilateral threads.
10 */
11public 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.