File: FIFOSlot.java

package info (click to toggle)
concurrent-dfsg 1.3.4-4
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, squeeze, stretch, wheezy
  • size: 976 kB
  • ctags: 2,018
  • sloc: java: 10,704; xml: 49; makefile: 12
file content (43 lines) | stat: -rw-r--r-- 904 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package EDU.oswego.cs.dl.util.concurrent.misc;
import  EDU.oswego.cs.dl.util.concurrent.*;


// demo showing one way to make special channels

public class FIFOSlot implements BoundedChannel {
  private final Slot slot_;

  public FIFOSlot() {
    try {
      slot_ = new Slot(FIFOSemaphore.class);
    }
    catch (Exception ex) {
      ex.printStackTrace();
      throw new Error("Cannot make Slot?");
    }
  }

  public void put(Object item) throws InterruptedException { 
    slot_.put(item); 
  }

  public boolean offer(Object item, long msecs) throws InterruptedException {
    return slot_.offer(item, msecs);
  }

  public Object take() throws InterruptedException { 
    return slot_.take(); 
  }

  public Object poll(long msecs) throws InterruptedException {
    return slot_.poll(msecs);
  }

  public int capacity() { return 1; }

  public Object peek() {
    return slot_.peek();
  }
}