Source code: rcs/utils/CorrectedPipeData.java
1 package rcs.utils;
2
3 /**
4 * Contains information used by CorrectedPipedInputStream and
5 * CorrectedPipedOutputStream.
6 *
7 * <pre>
8 * Related Documentation:
9 * <A HREF="http://isd.cme.nist.gov/proj/rcs_lib">RCS Library</a>, <A HREF="http://isd.cme.nist.gov/proj/rcs_lib/NMLjava.html">NML Programmers Guide (Java Version)</a>
10 *
11 * Source Code:
12 * <A HREF="CorrectedPipeData.java">CorrectedPipeData.java</a>
13 *
14 * </pre>
15 *
16 * @see rcs.utils.CorrectedPipedInputStream
17 * @see rcs.utils.CorrectedPipedOutputStream
18 *
19 * @author Will Shackleford -- <A HREF="mailto:shackle@cme.nist.gov">shackle@cme.nist.gov</a>
20 */
21 public class CorrectedPipeData
22 {
23 byte buffer[] = null;
24 int offset = 0;
25 int length = 0;
26 int wait_count = 0;
27 int notify_count = 0;
28
29 public synchronized void WaitForData() throws InterruptedException
30 {
31 if(notify_count > wait_count)
32 {
33 wait_count = notify_count;
34 return;
35 }
36 wait();
37 }
38
39 public synchronized void PostNewData()
40 {
41 if(notify_count < wait_count)
42 {
43 notify_count = wait_count;
44 }
45 notify_count++;
46 notifyAll();
47 }
48 }
49