okhttp: Document ForkJoinPool.managedBlock() usage example
When a client performs a blocking call, I think it makes sense to wrap the very blocking operation with ForkJoinPool.managedBlock()
. Many clients make HTTP calls from a ForkJoinPool
and don’t wrap such calls with ForkJoinPool.managedBlock()
themselves.
Another reason why the library itself rather than the clients should do this is that the library is able to isolate the very blocking operation while doing some other operations (such as compression/decompression, if it happens to be performed in the application-layer thread) outside of ForkJoinPool.managedBlock()
. Also, if the response for the call is cached, ForkJoinPool.managedBlock()
could be avoided inside the OkHttp library.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 15 (5 by maintainers)
The call is allocation-free for non-FJP theads, if memory serves.