Wrapper around java.nio.channels.Selector.
Wrapper around java.nio.channels.Selector.
(acceptable? key)Returns true if key's channel is ready to accept
a new socket connection.
Returns true if `key`'s channel is ready to accept a new socket connection.
(all-keys sel)Returns the set of all keys registered with sel, including those
not yet ready.
Returns the set of all keys registered with `sel`, including those not yet ready.
(attachment key)Returns the attachment associated with key, or nil if none.
Returns the attachment associated with `key`, or nil if none.
(channel key)Returns the channel associated with key.
Returns the channel associated with `key`.
(clear-keys! selected)Removes all keys from the selected-key set after processing.
Call this after all keys in selected have been handled.
Removes all keys from the selected-key set after processing. Call this after all keys in `selected` have been handled.
(connectable? key)Returns true if key's channel is ready to complete a connection.
Returns true if `key`'s channel is ready to complete a connection.
(deregister! key)Cancels key, removing its channel from the selector.
The key becomes invalid immediately. The cancellation
takes effect on the next select! call.
Cancels `key`, removing its channel from the selector. The key becomes invalid immediately. The cancellation takes effect on the next select! call.
(get-interests key)Retrieves this key's interest set. It is guaranteed that the returned set will only contain operation bits that are valid for this key's channel.
Retrieves this key's interest set. It is guaranteed that the returned set will only contain operation bits that are valid for this key's channel.
(readable? key)Returns true if key's channel is ready for reading.
Returns true if `key`'s channel is ready for reading.
(register! ch sel ops)(register! ch sel ops attachment)Registers channel ch with selector sel for
the given operations ops (a bitwise OR of
op-read, op-write, op-accept, op-connect).
Optionally accepts an attachment — any object — stored on the key
and retrievable via (attachment key). Useful for associating
per-channel state (e.g. a buffer, a handler, a connection id).
Returns the resulting SelectionKey.
Registers channel `ch` with selector `sel` for the given operations `ops` (a bitwise OR of op-read, op-write, op-accept, op-connect). Optionally accepts an `attachment` — any object — stored on the key and retrievable via (attachment key). Useful for associating per-channel state (e.g. a buffer, a handler, a connection id). Returns the resulting SelectionKey.
(select! sel)Selects a set of keys whose corresponding channels are ready for I/O operations. Blocks until at least one channel is ready for an operation it is registered for.
Selects a set of keys whose corresponding channels are ready for I/O operations. Blocks until at least one channel is ready for an operation it is registered for.
(select-now! sel)Non-blocking select. Returns immediately with the number of keys whose ready-op sets were updated since the last select call. Returns 0 if no channels are ready.
Non-blocking select. Returns immediately with the number of keys whose ready-op sets were updated since the last select call. Returns 0 if no channels are ready.
(select-timeout! sel timeout-ms)Like select!, but blocks for at most timeout-ms milliseconds.
Returns the number of keys whose ready-operation sets were updated.
Like select!, but blocks for at most `timeout-ms` milliseconds. Returns the number of keys whose ready-operation sets were updated.
(selected-keys sel)Returns the mutable Set of SelectionKeys that are ready.
Returns the mutable Set of SelectionKeys that are ready.
(selector)Opens and returns a new Selector.
Opens and returns a new Selector.
(set-interests! key ops)Updates the interest ops of key to ops.
Useful for switching a channel between read and write interest
mid-lifecycle, e.g. after accumulating a full response to send.
Returns key.
Updates the interest ops of `key` to `ops`. Useful for switching a channel between read and write interest mid-lifecycle, e.g. after accumulating a full response to send. Returns `key`.
(valid? key)Returns true if key is still registered with its selector.
Returns true if `key` is still registered with its selector.
(wakeup! sel)Causes the first selection operation that has
not yet returned to return immediately.
Returns sel.
Causes the first selection operation that has not yet returned to return immediately. Returns `sel`.
(writable? key)Returns true if key's channel is ready for writing.
Returns true if `key`'s channel is ready for writing.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |