src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1AsyncReceiver.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
362 "Subscribed pending " + delegate + " queue.isEmpty: " |
362 "Subscribed pending " + delegate + " queue.isEmpty: " |
363 + queue.isEmpty()); |
363 + queue.isEmpty()); |
364 // Everything may have been received already. Make sure |
364 // Everything may have been received already. Make sure |
365 // we parse it. |
365 // we parse it. |
366 if (client.isSelectorThread()) { |
366 if (client.isSelectorThread()) { |
367 scheduler.deferOrSchedule(executor); |
367 scheduler.runOrSchedule(executor); |
368 } else { |
368 } else { |
369 scheduler.runOrSchedule(); |
369 scheduler.runOrSchedule(); |
370 } |
370 } |
371 } |
371 } |
372 |
372 |
391 queue.offer(buf); |
391 queue.offer(buf); |
392 |
392 |
393 // This callback is called from within the selector thread. |
393 // This callback is called from within the selector thread. |
394 // Use an executor here to avoid doing the heavy lifting in the |
394 // Use an executor here to avoid doing the heavy lifting in the |
395 // selector. |
395 // selector. |
396 scheduler.deferOrSchedule(executor); |
396 scheduler.runOrSchedule(executor); |
397 } |
397 } |
398 |
398 |
399 // Callback: Consumer of Throwable |
399 // Callback: Consumer of Throwable |
400 void onReadError(Throwable ex) { |
400 void onReadError(Throwable ex) { |
401 Http1AsyncDelegate delegate; |
401 Http1AsyncDelegate delegate; |
432 } |
432 } |
433 if (queue.isEmpty() || pendingDelegateRef.get() != null) { |
433 if (queue.isEmpty() || pendingDelegateRef.get() != null) { |
434 // This callback is called from within the selector thread. |
434 // This callback is called from within the selector thread. |
435 // Use an executor here to avoid doing the heavy lifting in the |
435 // Use an executor here to avoid doing the heavy lifting in the |
436 // selector. |
436 // selector. |
437 scheduler.deferOrSchedule(executor); |
437 scheduler.runOrSchedule(executor); |
438 } |
438 } |
439 } |
439 } |
440 |
440 |
441 void stop() { |
441 void stop() { |
442 debug.log(Level.DEBUG, "stopping"); |
442 debug.log(Level.DEBUG, "stopping"); |
468 assert this.subscription == null || dropped == false; |
468 assert this.subscription == null || dropped == false; |
469 this.subscription = subscription; |
469 this.subscription = subscription; |
470 dropped = false; |
470 dropped = false; |
471 canRequestMore.set(true); |
471 canRequestMore.set(true); |
472 if (delegate != null) { |
472 if (delegate != null) { |
473 scheduler.deferOrSchedule(executor); |
473 scheduler.runOrSchedule(executor); |
474 } |
474 } |
475 } |
475 } |
476 |
476 |
477 void requestMore() { |
477 void requestMore() { |
478 Flow.Subscription s = subscription; |
478 Flow.Subscription s = subscription; |