Code - Class EDU.oswego.cs.dl.util.concurrent.misc.FIFOSlot


1 package EDU.oswego.cs.dl.util.concurrent.misc;
2 import EDU.oswego.cs.dl.util.concurrent.*;
3
4
5 // demo showing one way to make special channels
6

7 public class FIFOSlot implements BoundedChannel {
8   private final Slot slot_;
9
10   public FIFOSlot() {
11     try {
12       slot_ = new Slot(FIFOSemaphore.class);
13     }
14     catch (Exception ex) {
15       ex.printStackTrace();
16       throw new Error("Cannot make Slot?");
17     }
18   }
19
20   public void put(Object item) throws InterruptedException {
21     slot_.put(item);
22   }
23
24   public boolean offer(Object item, long msecs) throws InterruptedException {
25     return slot_.offer(item, msecs);
26   }
27
28   public Object take() throws InterruptedException {
29     return slot_.take();
30   }
31
32   public Object poll(long msecs) throws InterruptedException {
33     return slot_.poll(msecs);
34   }
35
36   public int capacity() { return 1; }
37
38   public Object peek() {
39     return slot_.peek();
40   }
41 }
42
43
44

Java API By Example, From Geeks To Geeks. | Conditions of Use | About Us © 2002 - 2005, KickJava.com, or its affiliates