const EVENT_READ
pub const EVENT_READ = 1Purpose
Constant EVENT_READ, defining protocol or algorithm parameters.
#net/pollerConnection registry for long-lived peers (gateway / 5k sessions). Linux and Darwin use a persistent EventSet. Windows batches the socket probes. Event tokens identify registrations independently of reused descriptors and slots.
const EVENT_READpub const EVENT_READ = 1Constant EVENT_READ, defining protocol or algorithm parameters.
const EVENT_WRITEpub const EVENT_WRITE = 2Constant EVENT_WRITE, defining protocol or algorithm parameters.
const EVENT_ERRORpub const EVENT_ERROR = 4Constant EVENT_ERROR, defining protocol or algorithm parameters.
const EVENT_HANGUPpub const EVENT_HANGUP = 8Constant EVENT_HANGUP, defining protocol or algorithm parameters.
struct Eventpub struct Event {
pub id int
pub events int
}Structure encapsulating id, events.
id intevents intstruct Pollerpub struct Poller {
}Poller context or state structure.
This type has no public fields.
newpub fn new() Pollernew creates an empty registry.
No arguments are required.
Poller — a value of this type
(&Poller) errpub fn (p &Poller) err() stringExecute err on &Poller.
p &PollerPoller instance used by this call (borrow).string — result string
($&Poller) addpub fn (p $&Poller) add(s stream.Stream) intadd registers a stream with default EVENT_READ interest. Returns a stable id (>0).
p $&PollerPoller instance used by this call (exclusive borrow).s stream.Streamint — a value of this type
($&Poller) add_interest_checkedpub fn (p $&Poller) add_interest_checked(s stream.Stream, interest int) intadd_interest_checked registers a stream with the specified event interest mask, rolling back slot allocation and throwing on EventSet watch failure. Throws on failure; handle the error or propagate it to the caller.
p $&PollerPoller instance used by this call (exclusive borrow).s stream.Streaminterest intint — a value of this type
($&Poller) add_interestpub fn (p $&Poller) add_interest(s stream.Stream, interest int) intadd_interest registers a stream with the specified event interest mask. Returns -1 (after rolling back slot allocation) on EventSet watch error.
p $&PollerPoller instance used by this call (exclusive borrow).s stream.Streaminterest intint — a value of this type
($&Poller) set_interestpub fn (p $&Poller) set_interest(id int, interest int) boolset_interest modifies event interest for an already registered stream.
p $&PollerPoller instance used by this call (exclusive borrow).id intinterest intbool — true or false
($&Poller) removepub fn (p $&Poller) remove(id int) boolremove drops the registration and its owned stream. Returns true if the id existed. Use close_id to observe an OS close error.
p $&PollerPoller instance used by this call (exclusive borrow).id intbool — true or false
(Poller) countpub fn (p Poller) count() intOperation on Poller: count non-overlapping occurrences.
p PollerPoller instance used by this call (value receiver).int — a value of this type
($&Poller) wait_checkedpub fn (p $&Poller) wait_checked(timeout_ns int) []Eventwait returns the descriptors that became ready. An empty registry returns immediately. With registered streams, zero blocks and a positive timeout is in nanoseconds. Throws on failure; handle the error or propagate it to the caller.
p $&PollerPoller instance used by this call (exclusive borrow).timeout_ns int[]Event — slice result
($&Poller) waitpub fn (p $&Poller) wait(timeout_ns int) []EventExecute wait on $&Poller.
p $&PollerPoller instance used by this call (exclusive borrow).timeout_ns int[]Event — slice result
($&Poller) read_timeoutpub fn (p $&Poller) read_timeout(id int, max int, timeout_ns int) stringread_timeout reads up to max bytes, applying a deadline of timeout_ns (0 = blocking). Empty string is EOF/timeout/error. The deadline is per operation. Conn applies it to SO_RCVTIMEO, so leaving it installed would make a later read inherit an already-expired timeout. Always clear it after the operation (including the error path). Throws on failure; handle the error or propagate it to the caller.
p $&PollerPoller instance used by this call (exclusive borrow).id intmax inttimeout_ns intstring — result string
($&Poller) write_allpub fn (p $&Poller) write_all(id int, data &string) intwrite_all writes the full buffer, looping across short writes. Throws on failure; handle the error or propagate it to the caller.
p $&PollerPoller instance used by this call (exclusive borrow).id intdata &stringint — a value of this type
($&Poller) close_idpub fn (p $&Poller) close_id(id int) boolclose_id closes and removes. Throws on failure; handle the error or propagate it to the caller.
p $&PollerPoller instance used by this call (exclusive borrow).id intbool — true or false
struct EventSetpub struct EventSet {
}A persistent, non-owning socket event set. Linux uses epoll and Darwin kqueue. Other hosted targets explicitly reject construction; the legacy Poller remains available there. A set is used by one owner at a time.
This type has no public fields.
struct EventWakepub struct EventWake {
}EventWake is a non-owning, copyable notification token for worker tasks. It does not close the EventSet; the owner must keep the set alive until all publishers have stopped.
This type has no public fields.
event_set_supportedpub fn event_set_supported() boolEvent set supported.
No arguments are required.
bool — true or false
new_event_setpub fn new_event_set() EventSetConstruct event set. Throws on failure; handle the error or propagate it to the caller.
No arguments are required.
EventSet — a value of this type
($&EventSet) watchpub fn (p $&EventSet) watch(fd int, token int, interest int) intwatch borrows fd and associates a caller-owned stable token. Closing the set does not close fd. Tokens must distinguish a reused connection slot an already-returned event may otherwise name a different connection. Throws on failure; handle the error or propagate it to the caller.
p $&EventSetEventSet instance used by this call (exclusive borrow).fd inttoken intinterest intint — a value of this type
($&EventSet) modifypub fn (p $&EventSet) modify(fd int, token int, interest int) intExecute modify on $&EventSet. Throws on failure; handle the error or propagate it to the caller.
p $&EventSetEventSet instance used by this call (exclusive borrow).fd inttoken intinterest intint — a value of this type
($&EventSet) removepub fn (p $&EventSet) remove(fd int) intremove tolerates a registration already removed by the kernel. Call it before closing/reusing fd; other invalid descriptor failures propagate. Throws on failure; handle the error or propagate it to the caller.
p $&EventSetEventSet instance used by this call (exclusive borrow).fd intint — a value of this type
($&EventSet) waitpub fn (p $&EventSet) wait(timeout_ns int) []Eventwait returns at most 64 events. timeout_ns: zero=infinite, negative=probe, positive=relative deadline. Signals may cause an empty early wake; callers with an absolute deadline recompute the remaining time. Darwin can return separate read/write events for one token. Readiness never reserves bytes. Throws on failure; handle the error or propagate it to the caller.
p $&EventSetEventSet instance used by this call (exclusive borrow).timeout_ns int[]Event — slice result
(&EventSet) wake_tokenpub fn (p &EventSet) wake_token() EventWakeOperation on &EventSet: wake token.
p &EventSetEventSet instance used by this call (borrow).EventWake — a value of this type
(&EventSet) wakepub fn (p &EventSet) wake() intExecute wake on &EventSet. Throws on failure; handle the error or propagate it to the caller.
p &EventSetEventSet instance used by this call (borrow).int — a value of this type
(EventWake) notifypub fn (w EventWake) notify() intExecute notify on EventWake. Throws on failure; handle the error or propagate it to the caller.
w EventWakeEventWake instance used by this call (value receiver).int — a value of this type
($&EventSet) closepub fn (p $&EventSet) close() intOperation on $&EventSet: close the resource. Throws on failure; handle the error or propagate it to the caller.
p $&EventSetEventSet instance used by this call (exclusive borrow).int — a value of this type