@@ -30,27 +30,27 @@ class Channel<T> {
30
30
T defaultVal = null ;
31
31
boolean closed = false ;
32
32
33
- public Channel () {
33
+ Channel () {
34
34
this (-1 );
35
35
}
36
36
37
- public Channel (LinkedBlockingQueue <T > queue ) {
37
+ Channel (LinkedBlockingQueue <T > queue ) {
38
38
q = queue ;
39
39
}
40
40
41
- public Channel (int capacity ) {
41
+ Channel (int capacity ) {
42
42
if (capacity <= 0 ) {
43
43
q = new LinkedBlockingQueue <T >();
44
44
} else {
45
45
q = new LinkedBlockingQueue <T >(capacity );
46
46
}
47
47
}
48
48
49
- public Channel (Collection <T > collection ) {
49
+ Channel (Collection <T > collection ) {
50
50
q = new LinkedBlockingQueue <T >(collection );
51
51
}
52
52
53
- public T get () {
53
+ T get () {
54
54
T result = defaultVal ;
55
55
try {
56
56
result = get (-1 , TimeUnit .MILLISECONDS );
@@ -61,11 +61,11 @@ public T get() {
61
61
return result ;
62
62
}
63
63
64
- public synchronized T get (long timeout ) throws TimeoutException {
64
+ synchronized T get (long timeout ) throws TimeoutException {
65
65
return (get (timeout , TimeUnit .MILLISECONDS ));
66
66
}
67
67
68
- public T get (long timeout , TimeUnit unit ) throws TimeoutException {
68
+ T get (long timeout , TimeUnit unit ) throws TimeoutException {
69
69
T item = defaultVal ;
70
70
71
71
try {
@@ -82,7 +82,7 @@ public T get(long timeout, TimeUnit unit) throws TimeoutException {
82
82
return item ;
83
83
}
84
84
85
- // public T getNew(long timeout, TimeUnit unit) throws TimeoutException {
85
+ // T getNew(long timeout, TimeUnit unit) throws TimeoutException {
86
86
// // System.err.printf("get called with timeout=%d, unit=%s\n", timeout, unit);
87
87
// T item = null;
88
88
// ExecutorService executor = Executors.newSingleThreadExecutor();
@@ -119,12 +119,12 @@ public T get(long timeout, TimeUnit unit) throws TimeoutException {
119
119
// }
120
120
121
121
122
- public T poll () {
122
+ T poll () {
123
123
return q .poll ();
124
124
}
125
125
126
126
// Will throw NullPointerException if you try to insert a null item
127
- public boolean add (T item ) {
127
+ boolean add (T item ) {
128
128
// offer(T e) is used here simply to eliminate exceptions. add returns false only
129
129
// if adding the item would have exceeded the capacity of a bounded queue.
130
130
if (isClosed ()) {
@@ -133,24 +133,24 @@ public boolean add(T item) {
133
133
return q .offer (item );
134
134
}
135
135
136
- public boolean add (T item , long timeout , TimeUnit unit ) throws InterruptedException {
136
+ boolean add (T item , long timeout , TimeUnit unit ) throws InterruptedException {
137
137
if (isClosed ()) {
138
138
return false ;
139
139
}
140
140
return q .offer (item , timeout , unit );
141
141
}
142
142
143
- public void close () {
143
+ void close () {
144
144
// logger.trace("Channel.close(), clearing queue");
145
145
closed = true ;
146
146
q .clear ();
147
147
}
148
148
149
- public boolean isClosed () {
149
+ boolean isClosed () {
150
150
return closed ;
151
151
}
152
152
153
- public int getCount () {
153
+ int getCount () {
154
154
return q .size ();
155
155
}
156
156
}
0 commit comments