MCPcopy Index your code
hub / github.com/koush/AndroidAsync / onWriteable

Method onWriteable

AndroidAsync/src/com/koushikdutta/async/Util.java:83–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

cleanupMethod · 0.95
hasRemainingMethod · 0.80
allocateMethod · 0.80
trackMethod · 0.80
onCompletedMethod · 0.65
addMethod · 0.65
writeMethod · 0.65
resumeMethod · 0.65
setWriteableCallbackMethod · 0.65
readMethod · 0.45
remainingMethod · 0.45

Tested by

no test coverage detected