source: src/main/java/bargainingchips/players/Coordinator.java@ 341

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

Change BilateralProtocol loop to avoid busy wait; note that this fixes only a part of the busy wait problem.

Package structure now in line with latest Acumex discussions.

Pinpointed error avoidance in Agent.

File size: 1.3 KB
Line 
1package bargainingchips.players;
2
3import java.util.concurrent.BlockingQueue;
4
5import bargainingchips.messaging.coordination.CoordinationMessage;
6import bargainingchips.messaging.status.StatusMessage;
7import bargainingchips.wishlist.WishList;
8
9/**
10 * The coordinator monitors and synchronizes all bilateral negotiation threads.
11 */
12public class Coordinator implements Runnable
13{
14 // Messages coming in and out of the coordinator
15 protected BlockingQueue<StatusMessage> cin;
16 protected BlockingQueue<CoordinationMessage> cout;
17 /** The fixed, initial wish list that should be obtained overall */
18 private WishList overallWishList;
19
20 public Coordinator(WishList wishlist, BlockingQueue<StatusMessage> negotiationMsg,
21 BlockingQueue<CoordinationMessage> coordinationMsg)
22 {
23 this.overallWishList = wishlist;
24 cin = negotiationMsg;
25 cout = coordinationMsg;
26 }
27
28 @Override
29 public void run()
30 {
31 // Send a very simple coordination message to Bob_i after a while
32 try {
33 Thread.sleep(2000);
34
35// UtilityFunction f = new UF_IWantColorAndQuantity("Green", 8);
36// CoordinationMessage coordinationMessage2 = new CoordinationMessage(f);
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.