()
| 81 | Allocator allocator = new Allocator().setMinAlloc((int)Math.min(2 << 19, max)); |
| 82 | |
| 83 | @Override |
| 84 | public void onWriteable() { |
| 85 | try { |
| 86 | do { |
| 87 | if (!pending.hasRemaining()) { |
| 88 | ByteBuffer b = allocator.allocate(); |
| 89 | |
| 90 | long toRead = Math.min(max - totalRead, b.capacity()); |
| 91 | int read = is.read(b.array(), 0, (int)toRead); |
| 92 | if (read == -1 || totalRead == max) { |
| 93 | cleanup(); |
| 94 | wrapper.onCompleted(null); |
| 95 | return; |
| 96 | } |
| 97 | allocator.track(read); |
| 98 | totalRead += read; |
| 99 | b.position(0); |
| 100 | b.limit(read); |
| 101 | pending.add(b); |
| 102 | } |
| 103 | |
| 104 | ds.write(pending); |
| 105 | } |
| 106 | while (!pending.hasRemaining()); |
| 107 | } |
| 108 | catch (Exception e) { |
| 109 | cleanup(); |
| 110 | wrapper.onCompleted(e); |
| 111 | } |
| 112 | } |
| 113 | }; |
| 114 | ds.setWriteableCallback(cb); |
| 115 |
nothing calls this directly
no test coverage detected