comparison src/fdl/FederatedLinda.java @ 101:d671c78d3757 fuchita

share selector in FDLindaServe and FederatedLinda
author one
date Wed, 26 May 2010 15:57:23 +0900
parents 270093b61001
children 8ae522e1a4bf
comparison
equal deleted inserted replaced
100:270093b61001 101:d671c78d3757
15 import java.io.IOException; 15 import java.io.IOException;
16 import java.nio.ByteBuffer; 16 import java.nio.ByteBuffer;
17 import java.nio.channels.ClosedSelectorException; 17 import java.nio.channels.ClosedSelectorException;
18 import java.nio.channels.SelectionKey; 18 import java.nio.channels.SelectionKey;
19 import java.nio.channels.Selector; 19 import java.nio.channels.Selector;
20 import java.nio.channels.spi.AbstractSelector;
20 import java.util.Hashtable; 21 import java.util.Hashtable;
21 import java.util.Iterator; 22 import java.util.Iterator;
22 import java.util.logging.Level; 23 import java.util.logging.Level;
23 24
24 /** 25 /**
47 48
48 public Selector selector; 49 public Selector selector;
49 50
50 public PSXQueue q_top,q_end; 51 public PSXQueue q_top,q_end;
51 public PSXReply r_top,r_end; 52 public PSXReply r_top,r_end;
52 public Hashtable<Integer,PSXReply> seqHash; 53 public Hashtable<Integer,PSXReply> seqHash = new Hashtable<Integer, PSXReply>();
53 54
54 public static FederatedLinda init() { 55 public static FederatedLinda init() {
55 FederatedLinda fdl = new FederatedLinda(); 56 FederatedLinda fdl = new FederatedLinda();
56 return fdl; 57 return fdl;
57 } 58 }
58 59
60 public static FederatedLinda init(Selector selector) {
61 FederatedLinda fdl = new FederatedLinda(selector);
62 return fdl;
63 }
64
59 private FederatedLinda() { 65 private FederatedLinda() {
60 try { 66 try {
61 selector = Selector.open(); 67 selector = Selector.open();
62 } catch (IOException e) { 68 } catch (IOException e) {
63 e.printStackTrace(); 69 e.printStackTrace();
64 } 70 }
65 seqHash = new Hashtable<Integer, PSXReply>(); 71 }
72
73 public FederatedLinda(Selector selector) {
74 this.selector = selector;
66 } 75 }
67 76
68 public PSXLinda open(String _host,int _port) 77 public PSXLinda open(String _host,int _port)
69 throws IOException { 78 throws IOException {
70 tid++; 79 tid++;
220 } 229 }
221 230
222 public void wakeup() { 231 public void wakeup() {
223 selector.wakeup(); 232 selector.wakeup();
224 } 233 }
234
225 } 235 }
226 236
227 /* end */ 237 /* end */