123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673 |
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <!-- This file is generated by Nim. -->
- <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>std/selectors</title>
- <!-- Google fonts -->
- <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
- <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
- <!-- Favicon -->
- <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
- <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
- <!-- CSS -->
- <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
- <!-- JS -->
- <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
- </head>
- <body>
- <div class="document" id="documentId">
- <div class="container">
- <h1 class="title">std/selectors</h1>
- <div class="row">
- <div class="three columns">
- <div class="theme-select-wrapper">
- <label for="theme-select">Theme: </label>
- <select id="theme-select" onchange="setTheme(this.value)">
- <option value="auto">🌗 Match OS</option>
- <option value="dark">🌑 Dark</option>
- <option value="light">🌕 Light</option>
- </select>
- </div>
- <div id="global-links">
- <ul class="simple-boot">
- <li><a href="manual.html">Manual</a></li>
- <li><a href="lib.html">Standard library</a></li>
- <li> <a id="indexLink" href="theindex.html">Index</a></li>
- <li><a href="compiler/theindex.html">Compiler docs</a></li>
- <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
- <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
- </ul>
- </div>
- <div id="searchInputDiv">
- Search: <input type="search" id="searchInput"
- oninput="search()" />
- </div>
-
- <ul class="simple simple-toc" id="toc-list">
- <li>
- <a class="reference reference-toplevel" href="#6" id="56">Imports</a>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
- <ul class="simple simple-toc-section">
- <li><a class="reference" href="#Event" title="Event {.pure.} = enum
- Read, ## Descriptor is available for read
- Write, ## Descriptor is available for write
- Timer, ## Timer descriptor is completed
- Signal, ## Signal is raised
- Process, ## Process is finished
- Vnode, ## BSD specific file change
- User, ## User event is raised
- Error, ## Error occurred while waiting for descriptor
- VnodeWrite, ## NOTE_WRITE (BSD specific, write to file occurred)
- VnodeDelete, ## NOTE_DELETE (BSD specific, unlink of file occurred)
- VnodeExtend, ## NOTE_EXTEND (BSD specific, file extended)
- VnodeAttrib, ## NOTE_ATTRIB (BSD specific, file attributes changed)
- VnodeLink, ## NOTE_LINK (BSD specific, file link count changed)
- VnodeRename, ## NOTE_RENAME (BSD specific, file renamed)
- VnodeRevoke ## NOTE_REVOKE (BSD specific, file revoke occurred)">Event</a></li>
- <li><a class="reference" href="#IOSelectorsException" title="IOSelectorsException = object of CatchableError">IOSelectorsException</a></li>
- <li><a class="reference" href="#ReadyKey" title="ReadyKey = object
- fd*: int ## file/socket descriptor
- events*: set[Event] ## set of events
- errorCode*: OSErrorCode ## additional error code information for
- ## Error events">ReadyKey</a></li>
- <li><a class="reference" href="#SelectEvent" title="SelectEvent = object">SelectEvent</a></li>
- <li><a class="reference" href="#Selector" title="Selector[T] = ref object">Selector</a></li>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
- <ul class="simple simple-toc-section">
- <li><a class="reference" href="#ioselSupportedPlatform" title="ioselSupportedPlatform = true">ioselSupportedPlatform</a></li>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
- <ul class="simple simple-toc-section">
- <ul class="simple nested-toc-section">close
- <li><a class="reference" href="#close%2CSelectEvent" title="close(ev: SelectEvent)">close(ev: SelectEvent)</a></li>
- <li><a class="reference" href="#close%2CSelector%5BT%5D" title="close[T](s: Selector[T])">close[T](s: Selector[T])</a></li>
- </ul>
- <ul class="simple nested-toc-section">contains
- <li><a class="reference" href="#contains%2CSelector%5BT%5D%2C" title="contains[T](s: Selector[T]; fd: SocketHandle | int): bool">contains[T](s: Selector[T]; fd: SocketHandle | int): bool</a></li>
- </ul>
- <ul class="simple nested-toc-section">getData
- <li><a class="reference" href="#getData%2CSelector%5BT%5D%2C" title="getData[T](s: Selector[T]; fd: SocketHandle | int): var T">getData[T](s: Selector[T]; fd: SocketHandle | int): var T</a></li>
- </ul>
- <ul class="simple nested-toc-section">getFd
- <li><a class="reference" href="#getFd%2CSelector%5BT%5D" title="getFd[T](s: Selector[T]): int">getFd[T](s: Selector[T]): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">newSelectEvent
- <li><a class="reference" href="#newSelectEvent" title="newSelectEvent(): SelectEvent">newSelectEvent(): SelectEvent</a></li>
- </ul>
- <ul class="simple nested-toc-section">newSelector
- <li><a class="reference" href="#newSelector" title="newSelector[T](): Selector[T]">newSelector[T](): Selector[T]</a></li>
- </ul>
- <ul class="simple nested-toc-section">registerEvent
- <li><a class="reference" href="#registerEvent%2CSelector%5BT%5D%2CSelectEvent%2CT" title="registerEvent[T](s: Selector[T]; ev: SelectEvent; data: T)">registerEvent[T](s: Selector[T]; ev: SelectEvent; data: T)</a></li>
- </ul>
- <ul class="simple nested-toc-section">registerHandle
- <li><a class="reference" href="#registerHandle%2CSelector%5BT%5D%2C%2Cset%5BEvent%5D%2CT" title="registerHandle[T](s: Selector[T]; fd: int | SocketHandle; events: set[Event];
- data: T)">registerHandle[T](s: Selector[T]; fd: int | SocketHandle; events: set[Event];
- data: T)</a></li>
- </ul>
- <ul class="simple nested-toc-section">registerProcess
- <li><a class="reference" href="#registerProcess%2CSelector%5BT%5D%2Cint%2CT" title="registerProcess[T](s: Selector[T]; pid: int; data: T): int">registerProcess[T](s: Selector[T]; pid: int; data: T): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">registerSignal
- <li><a class="reference" href="#registerSignal%2CSelector%5BT%5D%2Cint%2CT" title="registerSignal[T](s: Selector[T]; signal: int; data: T): int">registerSignal[T](s: Selector[T]; signal: int; data: T): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">registerTimer
- <li><a class="reference" href="#registerTimer%2CSelector%5BT%5D%2Cint%2Cbool%2CT" title="registerTimer[T](s: Selector[T]; timeout: int; oneshot: bool; data: T): int">registerTimer[T](s: Selector[T]; timeout: int; oneshot: bool; data: T): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">registerVnode
- <li><a class="reference" href="#registerVnode%2CSelector%5BT%5D%2Ccint%2Cset%5BEvent%5D%2CT" title="registerVnode[T](s: Selector[T]; fd: cint; events: set[Event]; data: T)">registerVnode[T](s: Selector[T]; fd: cint; events: set[Event]; data: T)</a></li>
- </ul>
- <ul class="simple nested-toc-section">select
- <li><a class="reference" href="#select%2CSelector%5BT%5D%2Cint" title="select[T](s: Selector[T]; timeout: int): seq[ReadyKey]">select[T](s: Selector[T]; timeout: int): seq[ReadyKey]</a></li>
- </ul>
- <ul class="simple nested-toc-section">selectInto
- <li><a class="reference" href="#selectInto%2CSelector%5BT%5D%2Cint%2CopenArray%5BReadyKey%5D" title="selectInto[T](s: Selector[T]; timeout: int; results: var openArray[ReadyKey]): int">selectInto[T](s: Selector[T]; timeout: int; results: var openArray[ReadyKey]): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">setData
- <li><a class="reference" href="#setData%2CSelector%5BT%5D%2C%2CT" title="setData[T](s: Selector[T]; fd: SocketHandle | int; data: var T): bool">setData[T](s: Selector[T]; fd: SocketHandle | int; data: var T): bool</a></li>
- </ul>
- <ul class="simple nested-toc-section">trigger
- <li><a class="reference" href="#trigger%2CSelectEvent" title="trigger(ev: SelectEvent)">trigger(ev: SelectEvent)</a></li>
- </ul>
- <ul class="simple nested-toc-section">unregister
- <li><a class="reference" href="#unregister%2CSelector%5BT%5D%2CSelectEvent" title="unregister[T](s: Selector[T]; ev: SelectEvent)">unregister[T](s: Selector[T]; ev: SelectEvent)</a></li>
- <li><a class="reference" href="#unregister%2CSelector%5BT%5D%2C" title="unregister[T](s: Selector[T]; fd: int | SocketHandle | cint)">unregister[T](s: Selector[T]; fd: int | SocketHandle | cint)</a></li>
- </ul>
- <ul class="simple nested-toc-section">updateHandle
- <li><a class="reference" href="#updateHandle%2CSelector%5BT%5D%2C%2Cset%5BEvent%5D" title="updateHandle[T](s: Selector[T]; fd: int | SocketHandle; events: set[Event])">updateHandle[T](s: Selector[T]; fd: int | SocketHandle; events: set[Event])</a></li>
- </ul>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#18" id="68">Templates</a></summary>
- <ul class="simple simple-toc-section">
- <ul class="simple nested-toc-section">isEmpty
- <li><a class="reference" href="#isEmpty.t%2CSelector%5BT%5D" title="isEmpty[T](s: Selector[T]): bool">isEmpty[T](s: Selector[T]): bool</a></li>
- </ul>
- <ul class="simple nested-toc-section">withData
- <li><a class="reference" href="#withData.t%2CSelector%5BT%5D%2C%2Cuntyped%2Cuntyped%2Cuntyped" title="withData[T](s: Selector[T]; fd: SocketHandle | int; value, body1, body2: untyped)">withData[T](s: Selector[T]; fd: SocketHandle | int; value, body1, body2: untyped)</a></li>
- <li><a class="reference" href="#withData.t%2CSelector%5BT%5D%2C%2Cuntyped%2Cuntyped" title="withData[T](s: Selector[T]; fd: SocketHandle | int; value, body: untyped)">withData[T](s: Selector[T]; fd: SocketHandle | int; value, body: untyped)</a></li>
- </ul>
- </ul>
- </details>
- </li>
- </ul>
- </div>
- <div class="nine columns" id="content">
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L1" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
- <div id="tocRoot"></div>
-
- <p class="module-desc"><p>This module allows high-level and efficient I/O multiplexing.</p>
- <p>Supported OS primitives: <tt class="docutils literal"><span class="pre"><span class="Identifier">epoll</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">kqueue</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">poll</span></span></tt> and Windows <tt class="docutils literal"><span class="pre"><span class="Identifier">select</span></span></tt>.</p>
- <p>To use threadsafe version of this module, it needs to be compiled with both <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">threadsafe</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Operator">--</span><span class="Identifier">threads</span><span class="Punctuation">:</span><span class="Identifier">on</span></span></tt> options.</p>
- <p>Supported features: files, sockets, pipes, timers, processes, signals and user events.</p>
- <p>Fully supported OS: MacOSX, FreeBSD, OpenBSD, NetBSD, Linux (except for Android).</p>
- <p>Partially supported OS: Windows (only sockets and user events), Solaris (files, sockets, handles and user events). Android (files, sockets, handles and user events).</p>
- <p>TODO: <tt class="docutils literal"><span class="pre"><span class="Operator">/</span><span class="Identifier">dev</span><span class="Operator">/</span><span class="Identifier">poll</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">event</span> <span class="Identifier">ports</span></span></tt> and filesystem events.</p>
- </p>
- <div class="section" id="6">
- <h1><a class="toc-backref" href="#6">Imports</a></h1>
- <dl class="item">
- <a class="reference external" href="nativesockets.html">nativesockets</a>, <a class="reference external" href="oserrors.html">oserrors</a>, <a class="reference external" href="assertions.html">assertions</a>
- </dl>
- </div>
- <div class="section" id="7">
- <h1><a class="toc-backref" href="#7">Types</a></h1>
- <dl class="item">
- <div id="Event">
- <dt><pre><a href="selectors.html#Event"><span class="Identifier">Event</span></a> {.<span class="Identifier">pure</span>.} <span class="Other">=</span> <span class="Keyword">enum</span>
- <span class="Identifier">Read</span><span class="Other">,</span> <span class="Comment">## Descriptor is available for read</span>
- <span class="Identifier">Write</span><span class="Other">,</span> <span class="Comment">## Descriptor is available for write</span>
- <span class="Identifier">Timer</span><span class="Other">,</span> <span class="Comment">## Timer descriptor is completed</span>
- <span class="Identifier">Signal</span><span class="Other">,</span> <span class="Comment">## Signal is raised</span>
- <span class="Identifier">Process</span><span class="Other">,</span> <span class="Comment">## Process is finished</span>
- <span class="Identifier">Vnode</span><span class="Other">,</span> <span class="Comment">## BSD specific file change</span>
- <span class="Identifier">User</span><span class="Other">,</span> <span class="Comment">## User event is raised</span>
- <span class="Identifier">Error</span><span class="Other">,</span> <span class="Comment">## Error occurred while waiting for descriptor</span>
- <span class="Identifier">VnodeWrite</span><span class="Other">,</span> <span class="Comment">## NOTE_WRITE (BSD specific, write to file occurred)</span>
- <span class="Identifier">VnodeDelete</span><span class="Other">,</span> <span class="Comment">## NOTE_DELETE (BSD specific, unlink of file occurred)</span>
- <span class="Identifier">VnodeExtend</span><span class="Other">,</span> <span class="Comment">## NOTE_EXTEND (BSD specific, file extended)</span>
- <span class="Identifier">VnodeAttrib</span><span class="Other">,</span> <span class="Comment">## NOTE_ATTRIB (BSD specific, file attributes changed)</span>
- <span class="Identifier">VnodeLink</span><span class="Other">,</span> <span class="Comment">## NOTE_LINK (BSD specific, file link count changed)</span>
- <span class="Identifier">VnodeRename</span><span class="Other">,</span> <span class="Comment">## NOTE_RENAME (BSD specific, file renamed)</span>
- <span class="Identifier">VnodeRevoke</span> <span class="Comment">## NOTE_REVOKE (BSD specific, file revoke occurred)</span></pre></dt>
- <dd>
-
- An enum which hold event types
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L57" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L57" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="IOSelectorsException">
- <dt><pre><a href="selectors.html#IOSelectorsException"><span class="Identifier">IOSelectorsException</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="system.html#CatchableError"><span class="Identifier">CatchableError</span></a></pre></dt>
- <dd>
-
- Exception that is raised if an IOSelectors error occurs.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L54" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L54" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="ReadyKey">
- <dt><pre><a href="selectors.html#ReadyKey"><span class="Identifier">ReadyKey</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
- <span class="Identifier">fd</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> <span class="Comment">## file/socket descriptor</span>
- <span class="Identifier">events</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="selectors.html#Event"><span class="Identifier">Event</span></a><span class="Other">]</span> <span class="Comment">## set of events</span>
- <span class="Identifier">errorCode</span><span class="Operator">*</span><span class="Other">:</span> <a href="oserrors.html#OSErrorCode"><span class="Identifier">OSErrorCode</span></a> <span class="Comment">## additional error code information for</span>
- <span class="Comment">## Error events</span></pre></dt>
- <dd>
-
- An object which holds result for descriptor
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L75" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L75" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="SelectEvent">
- <dt><pre><a href="selectors.html#SelectEvent"><span class="Identifier">SelectEvent</span></a> <span class="Other">=</span> <span class="Keyword">object</span></pre></dt>
- <dd>
-
- An object which holds user defined event
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L82" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L82" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="Selector">
- <dt><pre><a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span></pre></dt>
- <dd>
-
- An object which holds descriptors to be checked for read/write status
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L51" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L51" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </dl>
- </div>
- <div class="section" id="10">
- <h1><a class="toc-backref" href="#10">Consts</a></h1>
- <dl class="item">
- <div id="ioselSupportedPlatform">
- <dt><pre><a href="selectors.html#ioselSupportedPlatform"><span class="Identifier">ioselSupportedPlatform</span></a> <span class="Other">=</span> <span class="DecNumber">true</span></pre></dt>
- <dd>
-
- This constant is used to determine whether the destination platform is fully supported by <tt class="docutils literal"><span class="pre"><span class="Identifier">ioselectors</span></span></tt> module.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L38" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L38" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </dl>
- </div>
- <div class="section" id="12">
- <h1><a class="toc-backref" href="#12">Procs</a></h1>
- <dl class="item">
- <div id="close-procs-all">
- <div id="close,SelectEvent">
- <dt><pre><span class="Keyword">proc</span> <a href="#close%2CSelectEvent"><span class="Identifier">close</span></a><span class="Other">(</span><span class="Identifier">ev</span><span class="Other">:</span> <a href="selectors.html#SelectEvent"><span class="Identifier">SelectEvent</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Closes user-defined event <tt class="docutils literal"><span class="pre"><span class="Identifier">ev</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L159" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L159" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="close,Selector[T]">
- <dt><pre><span class="Keyword">proc</span> <a href="#close%2CSelector%5BT%5D"><span class="Identifier">close</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
- <dd>
-
- Closes the selector.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L88" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L88" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="contains-procs-all">
- <div id="contains,Selector[T],">
- <dt><pre><span class="Keyword">proc</span> <a href="#contains%2CSelector%5BT%5D%2C"><span class="Identifier">contains</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fd</span><span class="Other">:</span> <a href="winlean.html#SocketHandle"><span class="Identifier">SocketHandle</span></a> <span class="Operator">|</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">inline</span>.}</pre></dt>
- <dd>
-
- Determines whether selector contains a file descriptor.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L229" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L229" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="getData-procs-all">
- <div id="getData,Selector[T],">
- <dt><pre><span class="Keyword">proc</span> <a href="#getData%2CSelector%5BT%5D%2C"><span class="Identifier">getData</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fd</span><span class="Other">:</span> <a href="winlean.html#SocketHandle"><span class="Identifier">SocketHandle</span></a> <span class="Operator">|</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span></pre></dt>
- <dd>
-
- Retrieves application-defined <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> associated with descriptor <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt>. If specified descriptor <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt> is not registered, empty/default value will be returned.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L188" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L188" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="getFd-procs-all">
- <div id="getFd,Selector[T]">
- <dt><pre><span class="Keyword">proc</span> <a href="#getFd%2CSelector%5BT%5D"><span class="Identifier">getFd</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a></pre></dt>
- <dd>
-
- <p>Retrieves the underlying selector's file descriptor.</p>
- <p>For <em>poll</em> and <em>select</em> selectors <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="DecNumber">1</span></span></tt> is returned.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L232" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L232" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newSelectEvent-procs-all">
- <div id="newSelectEvent">
- <dt><pre><span class="Keyword">proc</span> <a href="#newSelectEvent"><span class="Identifier">newSelectEvent</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="selectors.html#SelectEvent"><span class="Identifier">SelectEvent</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Creates a new user-defined event.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L153" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L153" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newSelector-procs-all">
- <div id="newSelector">
- <dt><pre><span class="Keyword">proc</span> <a href="#newSelector"><span class="Identifier">newSelector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span></pre></dt>
- <dd>
-
- Creates a new selector
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L85" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L85" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="registerEvent-procs-all">
- <div id="registerEvent,Selector[T],SelectEvent,T">
- <dt><pre><span class="Keyword">proc</span> <a href="#registerEvent%2CSelector%5BT%5D%2CSelectEvent%2CT"><span class="Identifier">registerEvent</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">ev</span><span class="Other">:</span> <a href="selectors.html#SelectEvent"><span class="Identifier">SelectEvent</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span></pre></dt>
- <dd>
-
- <p>Registers selector event <tt class="docutils literal"><span class="pre"><span class="Identifier">ev</span></span></tt> in selector <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>.</p>
- <p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> is application-defined data, which will be passed when <tt class="docutils literal"><span class="pre"><span class="Identifier">ev</span></span></tt> happens.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L138" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L138" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="registerHandle-procs-all">
- <div id="registerHandle,Selector[T],,set[Event],T">
- <dt><pre><span class="Keyword">proc</span> <a href="#registerHandle%2CSelector%5BT%5D%2C%2Cset%5BEvent%5D%2CT"><span class="Identifier">registerHandle</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fd</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> <span class="Operator">|</span> <a href="winlean.html#SocketHandle"><span class="Identifier">SocketHandle</span></a><span class="Other">;</span>
- <span class="Identifier">events</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="selectors.html#Event"><span class="Identifier">Event</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span></pre></dt>
- <dd>
-
- Registers file/socket descriptor <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt> to selector <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> with events set in <tt class="docutils literal"><span class="pre"><span class="Identifier">events</span></span></tt>. The <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> is application-defined data, which will be passed when an event is triggered.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L91" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L91" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="registerProcess-procs-all">
- <div id="registerProcess,Selector[T],int,T">
- <dt><pre><span class="Keyword">proc</span> <a href="#registerProcess%2CSelector%5BT%5D%2Cint%2CT"><span class="Identifier">registerProcess</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">pid</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">discardable</span>.}</pre></dt>
- <dd>
-
- <p>Registers a process id (pid) notification (when process has exited) in selector <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>.</p>
- <p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> is application-defined data, which will be passed when process with <tt class="docutils literal"><span class="pre"><span class="Identifier">pid</span></span></tt> has exited.</p>
- <p>Returns the file descriptor for the registered signal.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L128" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L128" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="registerSignal-procs-all">
- <div id="registerSignal,Selector[T],int,T">
- <dt><pre><span class="Keyword">proc</span> <a href="#registerSignal%2CSelector%5BT%5D%2Cint%2CT"><span class="Identifier">registerSignal</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">signal</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">discardable</span>.}</pre></dt>
- <dd>
-
- <p>Registers Unix signal notification with <tt class="docutils literal"><span class="pre"><span class="Identifier">signal</span></span></tt> to selector <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>.</p>
- <p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> is application-defined data, which will be passed when signal raises.</p>
- <p>Returns the file descriptor for the registered signal.</p>
- <p><strong>Note:</strong> This function is not supported on <tt class="docutils literal"><span class="pre"><span class="Identifier">Windows</span></span></tt>.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L116" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L116" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="registerTimer-procs-all">
- <div id="registerTimer,Selector[T],int,bool,T">
- <dt><pre><span class="Keyword">proc</span> <a href="#registerTimer%2CSelector%5BT%5D%2Cint%2Cbool%2CT"><span class="Identifier">registerTimer</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">timeout</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">oneshot</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
- <span class="Identifier">discardable</span>.}</pre></dt>
- <dd>
-
- <p>Registers timer notification with <tt class="docutils literal"><span class="pre"><span class="Identifier">timeout</span></span></tt> (in milliseconds) to selector <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>.</p>
- <p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">oneshot</span></span></tt> is <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt>, timer will be notified only once.</p>
- <p>Set <tt class="docutils literal"><span class="pre"><span class="Identifier">oneshot</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">false</span></span></tt> if you want periodic notifications.</p>
- <p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> is application-defined data, which will be passed, when the timer is triggered.</p>
- <p>Returns the file descriptor for the registered timer.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L102" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L102" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="registerVnode-procs-all">
- <div id="registerVnode,Selector[T],cint,set[Event],T">
- <dt><pre><span class="Keyword">proc</span> <a href="#registerVnode%2CSelector%5BT%5D%2Ccint%2Cset%5BEvent%5D%2CT"><span class="Identifier">registerVnode</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fd</span><span class="Other">:</span> <a href="ctypes.html#cint"><span class="Identifier">cint</span></a><span class="Other">;</span> <span class="Identifier">events</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="selectors.html#Event"><span class="Identifier">Event</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span></pre></dt>
- <dd>
-
- <p>Registers selector BSD/MacOSX specific vnode events for file descriptor <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt> and events <tt class="docutils literal"><span class="pre"><span class="Identifier">events</span></span></tt>. <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> application-defined data, which to be passed, when vnode event happens.</p>
- <p><strong>Note:</strong> This function is supported only by BSD and MacOSX.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L144" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L144" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="select-procs-all">
- <div id="select,Selector[T],int">
- <dt><pre><span class="Keyword">proc</span> <a href="#select%2CSelector%5BT%5D%2Cint"><span class="Identifier">select</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">timeout</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="selectors.html#ReadyKey"><span class="Identifier">ReadyKey</span></a><span class="Other">]</span></pre></dt>
- <dd>
-
- <p>Waits for events registered in selector <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>.</p>
- <p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">timeout</span></span></tt> argument specifies the maximum number of milliseconds the function will be blocked for if no events are ready. Specifying a timeout of <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="DecNumber">1</span></span></tt> causes the function to block indefinitely.</p>
- <p>Returns a list of triggered events.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L179" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L179" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="selectInto-procs-all">
- <div id="selectInto,Selector[T],int,openArray[ReadyKey]">
- <dt><pre><span class="Keyword">proc</span> <a href="#selectInto%2CSelector%5BT%5D%2Cint%2CopenArray%5BReadyKey%5D"><span class="Identifier">selectInto</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">timeout</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span>
- <span class="Identifier">results</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="selectors.html#ReadyKey"><span class="Identifier">ReadyKey</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a></pre></dt>
- <dd>
-
- <p>Waits for events registered in selector <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>.</p>
- <p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">timeout</span></span></tt> argument specifies the maximum number of milliseconds the function will be blocked for if no events are ready. Specifying a timeout of <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="DecNumber">1</span></span></tt> causes the function to block indefinitely. All available events will be stored in <tt class="docutils literal"><span class="pre"><span class="Identifier">results</span></span></tt> array.</p>
- <p>Returns number of triggered events.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L168" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L168" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="setData-procs-all">
- <div id="setData,Selector[T],,T">
- <dt><pre><span class="Keyword">proc</span> <a href="#setData%2CSelector%5BT%5D%2C%2CT"><span class="Identifier">setData</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fd</span><span class="Other">:</span> <a href="winlean.html#SocketHandle"><span class="Identifier">SocketHandle</span></a> <span class="Operator">|</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a></pre></dt>
- <dd>
-
- <p>Associate application-defined <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> with descriptor <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt>.</p>
- <p>Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt>, if data was successfully updated, <tt class="docutils literal"><span class="pre"><span class="Identifier">false</span></span></tt> otherwise.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L193" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L193" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="trigger-procs-all">
- <div id="trigger,SelectEvent">
- <dt><pre><span class="Keyword">proc</span> <a href="#trigger%2CSelectEvent"><span class="Identifier">trigger</span></a><span class="Other">(</span><span class="Identifier">ev</span><span class="Other">:</span> <a href="selectors.html#SelectEvent"><span class="Identifier">SelectEvent</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Trigger event <tt class="docutils literal"><span class="pre"><span class="Identifier">ev</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L156" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L156" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="unregister-procs-all">
- <div id="unregister,Selector[T],SelectEvent">
- <dt><pre><span class="Keyword">proc</span> <a href="#unregister%2CSelector%5BT%5D%2CSelectEvent"><span class="Identifier">unregister</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">ev</span><span class="Other">:</span> <a href="selectors.html#SelectEvent"><span class="Identifier">SelectEvent</span></a><span class="Other">)</span></pre></dt>
- <dd>
-
- Unregisters user-defined event <tt class="docutils literal"><span class="pre"><span class="Identifier">ev</span></span></tt> from selector <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L162" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L162" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="unregister,Selector[T],">
- <dt><pre><span class="Keyword">proc</span> <a href="#unregister%2CSelector%5BT%5D%2C"><span class="Identifier">unregister</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fd</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> <span class="Operator">|</span> <a href="winlean.html#SocketHandle"><span class="Identifier">SocketHandle</span></a> <span class="Operator">|</span> <a href="ctypes.html#cint"><span class="Identifier">cint</span></a><span class="Other">)</span></pre></dt>
- <dd>
-
- Unregisters file/socket descriptor <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt> from selector <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L165" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L165" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="updateHandle-procs-all">
- <div id="updateHandle,Selector[T],,set[Event]">
- <dt><pre><span class="Keyword">proc</span> <a href="#updateHandle%2CSelector%5BT%5D%2C%2Cset%5BEvent%5D"><span class="Identifier">updateHandle</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fd</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> <span class="Operator">|</span> <a href="winlean.html#SocketHandle"><span class="Identifier">SocketHandle</span></a><span class="Other">;</span> <span class="Identifier">events</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="selectors.html#Event"><span class="Identifier">Event</span></a><span class="Other">]</span><span class="Other">)</span></pre></dt>
- <dd>
-
- Update file/socket descriptor <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt>, registered in selector <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> with new events set <tt class="docutils literal"><span class="pre"><span class="Identifier">event</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L97" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L97" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- <div class="section" id="18">
- <h1><a class="toc-backref" href="#18">Templates</a></h1>
- <dl class="item">
- <div id="isEmpty-templates-all">
- <div id="isEmpty.t,Selector[T]">
- <dt><pre><span class="Keyword">template</span> <a href="#isEmpty.t%2CSelector%5BT%5D"><span class="Identifier">isEmpty</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a></pre></dt>
- <dd>
-
- Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt>, if there are no registered events or descriptors in selector.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L198" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L198" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="withData-templates-all">
- <div id="withData.t,Selector[T],,untyped,untyped,untyped">
- <dt><pre><span class="Keyword">template</span> <a href="#withData.t%2CSelector%5BT%5D%2C%2Cuntyped%2Cuntyped%2Cuntyped"><span class="Identifier">withData</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fd</span><span class="Other">:</span> <a href="winlean.html#SocketHandle"><span class="Identifier">SocketHandle</span></a> <span class="Operator">|</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span>
- <span class="Identifier">value</span><span class="Other">,</span> <span class="Identifier">body1</span><span class="Other">,</span> <span class="Identifier">body2</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span></pre></dt>
- <dd>
-
- <p>Retrieves the application-data assigned with descriptor <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt>. This <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt> can be modified in the scope of the <tt class="docutils literal"><span class="pre"><span class="Identifier">withData</span></span></tt> call.</p>
- <p><pre class="listing"><span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">withData</span><span class="Punctuation">(</span><span class="Identifier">fd</span><span class="Punctuation">,</span> <span class="Identifier">value</span><span class="Punctuation">)</span> <span class="Keyword">do</span><span class="Punctuation">:</span>
- <span class="Comment"># block is executed only if `fd` registered in selector `s`.</span>
- <span class="Identifier">value</span><span class="Operator">.</span><span class="Identifier">uid</span> <span class="Operator">=</span> <span class="DecNumber">1000</span>
- <span class="Keyword">do</span><span class="Punctuation">:</span>
- <span class="Comment"># block is executed if `fd` not registered in selector `s`.</span>
- <span class="Keyword">raise</span></pre></p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L214" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L214" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="withData.t,Selector[T],,untyped,untyped">
- <dt><pre><span class="Keyword">template</span> <a href="#withData.t%2CSelector%5BT%5D%2C%2Cuntyped%2Cuntyped"><span class="Identifier">withData</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="selectors.html#Selector"><span class="Identifier">Selector</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fd</span><span class="Other">:</span> <a href="winlean.html#SocketHandle"><span class="Identifier">SocketHandle</span></a> <span class="Operator">|</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span>
- <span class="Identifier">value</span><span class="Other">,</span> <span class="Identifier">body</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span></pre></dt>
- <dd>
-
- <p>Retrieves the application-data assigned with descriptor <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt>. This <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt> can be modified in the scope of the <tt class="docutils literal"><span class="pre"><span class="Identifier">withData</span></span></tt> call.</p>
- <p><pre class="listing"><span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">withData</span><span class="Punctuation">(</span><span class="Identifier">fd</span><span class="Punctuation">,</span> <span class="Identifier">value</span><span class="Punctuation">)</span> <span class="Keyword">do</span><span class="Punctuation">:</span>
- <span class="Comment"># block is executed only if `fd` registered in selector `s`</span>
- <span class="Identifier">value</span><span class="Operator">.</span><span class="Identifier">uid</span> <span class="Operator">=</span> <span class="DecNumber">1000</span></pre></p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L202" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L202" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- </div>
- </div>
- <div class="twelve-columns footer">
- <span class="nim-sprite"></span>
- <br>
- <small style="color: var(--hint);">Made with Nim. Generated: 2024-12-25 13:28:11 UTC</small>
- </div>
- </div>
- </div>
- <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
-
- </body>
- </html>
|