Description
A DESCRIPTION OF THE REQUEST :
The API documentation never notes that a register() can block.
JUSTIFICATION :
The API should make a note of this... otherwise, a developer will only notice this by accident (i.e. the application locks up and makes no progress).
An alternative which is a bit harder is to make register() non-blocking (this would be ideal).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The documentation should be updated to make a note of the behavior, or the implementation changed so that register() does not block.
ACTUAL -
Trying to register() a SocketChannel on a selector that is blocked in a select() will result in register() hanging until the selector wakes up.
CUSTOMER SUBMITTED WORKAROUND :
Use select() with a timeout and hope the thread running register() makes progress (this is a potential race), or build a Queue of Runnables that perform the appropriate registrations that the selection thread can run before entering the next select.
The API documentation never notes that a register() can block.
JUSTIFICATION :
The API should make a note of this... otherwise, a developer will only notice this by accident (i.e. the application locks up and makes no progress).
An alternative which is a bit harder is to make register() non-blocking (this would be ideal).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The documentation should be updated to make a note of the behavior, or the implementation changed so that register() does not block.
ACTUAL -
Trying to register() a SocketChannel on a selector that is blocked in a select() will result in register() hanging until the selector wakes up.
CUSTOMER SUBMITTED WORKAROUND :
Use select() with a timeout and hope the thread running register() makes progress (this is a potential race), or build a Queue of Runnables that perform the appropriate registrations that the selection thread can run before entering the next select.