comparison src/EDU/oswego/cs/dl/util/concurrent/misc/FIFOSlot.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3dc0c5604566
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