src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/Receiver.java
equal
deleted
inserted
replaced
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package jdk.incubator.http.internal.websocket; |
26 package jdk.incubator.http.internal.websocket; |
27 |
27 |
|
28 import jdk.incubator.http.internal.common.Demand; |
|
29 import jdk.incubator.http.internal.common.SequentialScheduler; |
|
30 |
28 import java.io.IOException; |
31 import java.io.IOException; |
29 import java.nio.ByteBuffer; |
32 import java.nio.ByteBuffer; |
30 import java.nio.channels.SelectionKey; |
33 import java.nio.channels.SelectionKey; |
31 |
|
32 import jdk.incubator.http.internal.common.Demand; |
|
33 import jdk.incubator.http.internal.common.SequentialScheduler; |
|
34 |
34 |
35 /* |
35 /* |
36 * Receives incoming data from the channel on demand and converts it into a |
36 * Receives incoming data from the channel on demand and converts it into a |
37 * stream of WebSocket messages which are then delivered to the supplied message |
37 * stream of WebSocket messages which are then delivered to the supplied message |
38 * consumer in a strict sequential order and non-recursively. In other words, |
38 * consumer in a strict sequential order and non-recursively. In other words, |
99 } |
99 } |
100 }; |
100 }; |
101 } |
101 } |
102 |
102 |
103 public void request(long n) { |
103 public void request(long n) { |
104 if (n <= 0L) { |
104 if (demand.increase(n)) { |
105 throw new IllegalArgumentException("Non-positive request: " + n); |
105 pushScheduler.runOrSchedule(); |
106 } |
106 } |
107 demand.increase(n); |
|
108 pushScheduler.runOrSchedule(); |
|
109 } |
107 } |
110 |
108 |
111 /* |
109 /* |
112 * Why is this method needed? Since Receiver operates through callbacks |
110 * Why is this method needed? Since Receiver operates through callbacks |
113 * this method allows to abstract out what constitutes as a message being |
111 * this method allows to abstract out what constitutes as a message being |