selectors.html 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <!-- This file is generated by Nim. -->
  4. <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>std/selectors</title>
  9. <!-- Google fonts -->
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
  11. <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
  12. <!-- Favicon -->
  13. <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=="/>
  14. <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=">
  15. <!-- CSS -->
  16. <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
  17. <!-- JS -->
  18. <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
  19. </head>
  20. <body>
  21. <div class="document" id="documentId">
  22. <div class="container">
  23. <h1 class="title">std/selectors</h1>
  24. <div class="row">
  25. <div class="three columns">
  26. <div class="theme-select-wrapper">
  27. <label for="theme-select">Theme:&nbsp;</label>
  28. <select id="theme-select" onchange="setTheme(this.value)">
  29. <option value="auto">🌗 Match OS</option>
  30. <option value="dark">🌑 Dark</option>
  31. <option value="light">🌕 Light</option>
  32. </select>
  33. </div>
  34. <div id="global-links">
  35. <ul class="simple-boot">
  36. <li><a href="manual.html">Manual</a></li>
  37. <li><a href="lib.html">Standard library</a></li>
  38. <li> <a id="indexLink" href="theindex.html">Index</a></li>
  39. <li><a href="compiler/theindex.html">Compiler docs</a></li>
  40. <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
  41. <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
  42. </ul>
  43. </div>
  44. <div id="searchInputDiv">
  45. Search: <input type="search" id="searchInput"
  46. oninput="search()" />
  47. </div>
  48. <ul class="simple simple-toc" id="toc-list">
  49. <li>
  50. <a class="reference reference-toplevel" href="#6" id="56">Imports</a>
  51. </li>
  52. <li>
  53. <details open>
  54. <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
  55. <ul class="simple simple-toc-section">
  56. <li><a class="reference" href="#Event" title="Event {.pure.} = enum
  57. Read, ## Descriptor is available for read
  58. Write, ## Descriptor is available for write
  59. Timer, ## Timer descriptor is completed
  60. Signal, ## Signal is raised
  61. Process, ## Process is finished
  62. Vnode, ## BSD specific file change
  63. User, ## User event is raised
  64. Error, ## Error occurred while waiting for descriptor
  65. VnodeWrite, ## NOTE_WRITE (BSD specific, write to file occurred)
  66. VnodeDelete, ## NOTE_DELETE (BSD specific, unlink of file occurred)
  67. VnodeExtend, ## NOTE_EXTEND (BSD specific, file extended)
  68. VnodeAttrib, ## NOTE_ATTRIB (BSD specific, file attributes changed)
  69. VnodeLink, ## NOTE_LINK (BSD specific, file link count changed)
  70. VnodeRename, ## NOTE_RENAME (BSD specific, file renamed)
  71. VnodeRevoke ## NOTE_REVOKE (BSD specific, file revoke occurred)">Event</a></li>
  72. <li><a class="reference" href="#IOSelectorsException" title="IOSelectorsException = object of CatchableError">IOSelectorsException</a></li>
  73. <li><a class="reference" href="#ReadyKey" title="ReadyKey = object
  74. fd*: int ## file/socket descriptor
  75. events*: set[Event] ## set of events
  76. errorCode*: OSErrorCode ## additional error code information for
  77. ## Error events">ReadyKey</a></li>
  78. <li><a class="reference" href="#SelectEvent" title="SelectEvent = object">SelectEvent</a></li>
  79. <li><a class="reference" href="#Selector" title="Selector[T] = ref object">Selector</a></li>
  80. </ul>
  81. </details>
  82. </li>
  83. <li>
  84. <details open>
  85. <summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
  86. <ul class="simple simple-toc-section">
  87. <li><a class="reference" href="#ioselSupportedPlatform" title="ioselSupportedPlatform = true">ioselSupportedPlatform</a></li>
  88. </ul>
  89. </details>
  90. </li>
  91. <li>
  92. <details open>
  93. <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
  94. <ul class="simple simple-toc-section">
  95. <ul class="simple nested-toc-section">close
  96. <li><a class="reference" href="#close%2CSelectEvent" title="close(ev: SelectEvent)">close(ev: SelectEvent)</a></li>
  97. <li><a class="reference" href="#close%2CSelector%5BT%5D" title="close[T](s: Selector[T])">close[T](s: Selector[T])</a></li>
  98. </ul>
  99. <ul class="simple nested-toc-section">contains
  100. <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>
  101. </ul>
  102. <ul class="simple nested-toc-section">getData
  103. <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>
  104. </ul>
  105. <ul class="simple nested-toc-section">getFd
  106. <li><a class="reference" href="#getFd%2CSelector%5BT%5D" title="getFd[T](s: Selector[T]): int">getFd[T](s: Selector[T]): int</a></li>
  107. </ul>
  108. <ul class="simple nested-toc-section">newSelectEvent
  109. <li><a class="reference" href="#newSelectEvent" title="newSelectEvent(): SelectEvent">newSelectEvent(): SelectEvent</a></li>
  110. </ul>
  111. <ul class="simple nested-toc-section">newSelector
  112. <li><a class="reference" href="#newSelector" title="newSelector[T](): Selector[T]">newSelector[T](): Selector[T]</a></li>
  113. </ul>
  114. <ul class="simple nested-toc-section">registerEvent
  115. <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>
  116. </ul>
  117. <ul class="simple nested-toc-section">registerHandle
  118. <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];
  119. data: T)">registerHandle[T](s: Selector[T]; fd: int | SocketHandle; events: set[Event];
  120. data: T)</a></li>
  121. </ul>
  122. <ul class="simple nested-toc-section">registerProcess
  123. <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>
  124. </ul>
  125. <ul class="simple nested-toc-section">registerSignal
  126. <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>
  127. </ul>
  128. <ul class="simple nested-toc-section">registerTimer
  129. <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>
  130. </ul>
  131. <ul class="simple nested-toc-section">registerVnode
  132. <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>
  133. </ul>
  134. <ul class="simple nested-toc-section">select
  135. <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>
  136. </ul>
  137. <ul class="simple nested-toc-section">selectInto
  138. <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>
  139. </ul>
  140. <ul class="simple nested-toc-section">setData
  141. <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>
  142. </ul>
  143. <ul class="simple nested-toc-section">trigger
  144. <li><a class="reference" href="#trigger%2CSelectEvent" title="trigger(ev: SelectEvent)">trigger(ev: SelectEvent)</a></li>
  145. </ul>
  146. <ul class="simple nested-toc-section">unregister
  147. <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>
  148. <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>
  149. </ul>
  150. <ul class="simple nested-toc-section">updateHandle
  151. <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>
  152. </ul>
  153. </ul>
  154. </details>
  155. </li>
  156. <li>
  157. <details open>
  158. <summary><a class="reference reference-toplevel" href="#18" id="68">Templates</a></summary>
  159. <ul class="simple simple-toc-section">
  160. <ul class="simple nested-toc-section">isEmpty
  161. <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>
  162. </ul>
  163. <ul class="simple nested-toc-section">withData
  164. <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>
  165. <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>
  166. </ul>
  167. </ul>
  168. </details>
  169. </li>
  170. </ul>
  171. </div>
  172. <div class="nine columns" id="content">
  173. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  174. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  175. <div id="tocRoot"></div>
  176. <p class="module-desc"><p>This module allows high-level and efficient I/O multiplexing.</p>
  177. <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>
  178. <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>
  179. <p>Supported features: files, sockets, pipes, timers, processes, signals and user events.</p>
  180. <p>Fully supported OS: MacOSX, FreeBSD, OpenBSD, NetBSD, Linux (except for Android).</p>
  181. <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>
  182. <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>
  183. </p>
  184. <div class="section" id="6">
  185. <h1><a class="toc-backref" href="#6">Imports</a></h1>
  186. <dl class="item">
  187. <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>
  188. </dl>
  189. </div>
  190. <div class="section" id="7">
  191. <h1><a class="toc-backref" href="#7">Types</a></h1>
  192. <dl class="item">
  193. <div id="Event">
  194. <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>
  195. <span class="Identifier">Read</span><span class="Other">,</span> <span class="Comment">## Descriptor is available for read</span>
  196. <span class="Identifier">Write</span><span class="Other">,</span> <span class="Comment">## Descriptor is available for write</span>
  197. <span class="Identifier">Timer</span><span class="Other">,</span> <span class="Comment">## Timer descriptor is completed</span>
  198. <span class="Identifier">Signal</span><span class="Other">,</span> <span class="Comment">## Signal is raised</span>
  199. <span class="Identifier">Process</span><span class="Other">,</span> <span class="Comment">## Process is finished</span>
  200. <span class="Identifier">Vnode</span><span class="Other">,</span> <span class="Comment">## BSD specific file change</span>
  201. <span class="Identifier">User</span><span class="Other">,</span> <span class="Comment">## User event is raised</span>
  202. <span class="Identifier">Error</span><span class="Other">,</span> <span class="Comment">## Error occurred while waiting for descriptor</span>
  203. <span class="Identifier">VnodeWrite</span><span class="Other">,</span> <span class="Comment">## NOTE_WRITE (BSD specific, write to file occurred)</span>
  204. <span class="Identifier">VnodeDelete</span><span class="Other">,</span> <span class="Comment">## NOTE_DELETE (BSD specific, unlink of file occurred)</span>
  205. <span class="Identifier">VnodeExtend</span><span class="Other">,</span> <span class="Comment">## NOTE_EXTEND (BSD specific, file extended)</span>
  206. <span class="Identifier">VnodeAttrib</span><span class="Other">,</span> <span class="Comment">## NOTE_ATTRIB (BSD specific, file attributes changed)</span>
  207. <span class="Identifier">VnodeLink</span><span class="Other">,</span> <span class="Comment">## NOTE_LINK (BSD specific, file link count changed)</span>
  208. <span class="Identifier">VnodeRename</span><span class="Other">,</span> <span class="Comment">## NOTE_RENAME (BSD specific, file renamed)</span>
  209. <span class="Identifier">VnodeRevoke</span> <span class="Comment">## NOTE_REVOKE (BSD specific, file revoke occurred)</span></pre></dt>
  210. <dd>
  211. An enum which hold event types
  212. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L57" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  213. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L57" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  214. </dd>
  215. </div>
  216. <div id="IOSelectorsException">
  217. <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>
  218. <dd>
  219. Exception that is raised if an IOSelectors error occurs.
  220. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L54" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  221. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L54" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  222. </dd>
  223. </div>
  224. <div id="ReadyKey">
  225. <dt><pre><a href="selectors.html#ReadyKey"><span class="Identifier">ReadyKey</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
  226. <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>
  227. <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>
  228. <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>
  229. <span class="Comment">## Error events</span></pre></dt>
  230. <dd>
  231. An object which holds result for descriptor
  232. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L75" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  233. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L75" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  234. </dd>
  235. </div>
  236. <div id="SelectEvent">
  237. <dt><pre><a href="selectors.html#SelectEvent"><span class="Identifier">SelectEvent</span></a> <span class="Other">=</span> <span class="Keyword">object</span></pre></dt>
  238. <dd>
  239. An object which holds user defined event
  240. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L82" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  241. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L82" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  242. </dd>
  243. </div>
  244. <div id="Selector">
  245. <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>
  246. <dd>
  247. An object which holds descriptors to be checked for read/write status
  248. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L51" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  249. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L51" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  250. </dd>
  251. </div>
  252. </dl>
  253. </div>
  254. <div class="section" id="10">
  255. <h1><a class="toc-backref" href="#10">Consts</a></h1>
  256. <dl class="item">
  257. <div id="ioselSupportedPlatform">
  258. <dt><pre><a href="selectors.html#ioselSupportedPlatform"><span class="Identifier">ioselSupportedPlatform</span></a> <span class="Other">=</span> <span class="DecNumber">true</span></pre></dt>
  259. <dd>
  260. 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.
  261. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L38" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  262. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L38" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  263. </dd>
  264. </div>
  265. </dl>
  266. </div>
  267. <div class="section" id="12">
  268. <h1><a class="toc-backref" href="#12">Procs</a></h1>
  269. <dl class="item">
  270. <div id="close-procs-all">
  271. <div id="close,SelectEvent">
  272. <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>
  273. <dd>
  274. Closes user-defined event <tt class="docutils literal"><span class="pre"><span class="Identifier">ev</span></span></tt>.
  275. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L159" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  276. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L159" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  277. </dd>
  278. </div>
  279. <div id="close,Selector[T]">
  280. <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>
  281. <dd>
  282. Closes the selector.
  283. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L88" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  284. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L88" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  285. </dd>
  286. </div>
  287. </div>
  288. <div id="contains-procs-all">
  289. <div id="contains,Selector[T],">
  290. <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>
  291. <dd>
  292. Determines whether selector contains a file descriptor.
  293. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L229" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  294. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L229" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  295. </dd>
  296. </div>
  297. </div>
  298. <div id="getData-procs-all">
  299. <div id="getData,Selector[T],">
  300. <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>
  301. <dd>
  302. 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.
  303. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L188" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  304. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L188" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  305. </dd>
  306. </div>
  307. </div>
  308. <div id="getFd-procs-all">
  309. <div id="getFd,Selector[T]">
  310. <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>
  311. <dd>
  312. <p>Retrieves the underlying selector's file descriptor.</p>
  313. <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>
  314. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L232" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  315. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L232" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  316. </dd>
  317. </div>
  318. </div>
  319. <div id="newSelectEvent-procs-all">
  320. <div id="newSelectEvent">
  321. <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>
  322. <dd>
  323. Creates a new user-defined event.
  324. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L153" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  325. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L153" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  326. </dd>
  327. </div>
  328. </div>
  329. <div id="newSelector-procs-all">
  330. <div id="newSelector">
  331. <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>
  332. <dd>
  333. Creates a new selector
  334. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L85" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  335. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L85" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  336. </dd>
  337. </div>
  338. </div>
  339. <div id="registerEvent-procs-all">
  340. <div id="registerEvent,Selector[T],SelectEvent,T">
  341. <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>
  342. <dd>
  343. <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>
  344. <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>
  345. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L138" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  346. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L138" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  347. </dd>
  348. </div>
  349. </div>
  350. <div id="registerHandle-procs-all">
  351. <div id="registerHandle,Selector[T],,set[Event],T">
  352. <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>
  353. <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>
  354. <dd>
  355. 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.
  356. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L91" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  357. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L91" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  358. </dd>
  359. </div>
  360. </div>
  361. <div id="registerProcess-procs-all">
  362. <div id="registerProcess,Selector[T],int,T">
  363. <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>
  364. <dd>
  365. <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>
  366. <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>
  367. <p>Returns the file descriptor for the registered signal.</p>
  368. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L128" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  369. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L128" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  370. </dd>
  371. </div>
  372. </div>
  373. <div id="registerSignal-procs-all">
  374. <div id="registerSignal,Selector[T],int,T">
  375. <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>
  376. <dd>
  377. <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>
  378. <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>
  379. <p>Returns the file descriptor for the registered signal.</p>
  380. <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>
  381. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L116" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  382. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L116" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  383. </dd>
  384. </div>
  385. </div>
  386. <div id="registerTimer-procs-all">
  387. <div id="registerTimer,Selector[T],int,bool,T">
  388. <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> {.
  389. <span class="Identifier">discardable</span>.}</pre></dt>
  390. <dd>
  391. <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>
  392. <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>
  393. <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>
  394. <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>
  395. <p>Returns the file descriptor for the registered timer.</p>
  396. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L102" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  397. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L102" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  398. </dd>
  399. </div>
  400. </div>
  401. <div id="registerVnode-procs-all">
  402. <div id="registerVnode,Selector[T],cint,set[Event],T">
  403. <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>
  404. <dd>
  405. <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>
  406. <p><strong>Note:</strong> This function is supported only by BSD and MacOSX.</p>
  407. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L144" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  408. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L144" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  409. </dd>
  410. </div>
  411. </div>
  412. <div id="select-procs-all">
  413. <div id="select,Selector[T],int">
  414. <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>
  415. <dd>
  416. <p>Waits for events registered in selector <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>.</p>
  417. <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>
  418. <p>Returns a list of triggered events.</p>
  419. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L179" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  420. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L179" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  421. </dd>
  422. </div>
  423. </div>
  424. <div id="selectInto-procs-all">
  425. <div id="selectInto,Selector[T],int,openArray[ReadyKey]">
  426. <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>
  427. <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>
  428. <dd>
  429. <p>Waits for events registered in selector <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>.</p>
  430. <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>
  431. <p>Returns number of triggered events.</p>
  432. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L168" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  433. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L168" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  434. </dd>
  435. </div>
  436. </div>
  437. <div id="setData-procs-all">
  438. <div id="setData,Selector[T],,T">
  439. <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>
  440. <dd>
  441. <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>
  442. <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>
  443. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L193" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  444. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L193" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  445. </dd>
  446. </div>
  447. </div>
  448. <div id="trigger-procs-all">
  449. <div id="trigger,SelectEvent">
  450. <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>
  451. <dd>
  452. Trigger event <tt class="docutils literal"><span class="pre"><span class="Identifier">ev</span></span></tt>.
  453. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L156" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  454. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L156" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  455. </dd>
  456. </div>
  457. </div>
  458. <div id="unregister-procs-all">
  459. <div id="unregister,Selector[T],SelectEvent">
  460. <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>
  461. <dd>
  462. 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>.
  463. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L162" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  464. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L162" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  465. </dd>
  466. </div>
  467. <div id="unregister,Selector[T],">
  468. <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>
  469. <dd>
  470. 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>.
  471. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L165" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  472. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L165" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  473. </dd>
  474. </div>
  475. </div>
  476. <div id="updateHandle-procs-all">
  477. <div id="updateHandle,Selector[T],,set[Event]">
  478. <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>
  479. <dd>
  480. 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>.
  481. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L97" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  482. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L97" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  483. </dd>
  484. </div>
  485. </div>
  486. </dl>
  487. </div>
  488. <div class="section" id="18">
  489. <h1><a class="toc-backref" href="#18">Templates</a></h1>
  490. <dl class="item">
  491. <div id="isEmpty-templates-all">
  492. <div id="isEmpty.t,Selector[T]">
  493. <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>
  494. <dd>
  495. 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.
  496. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L198" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  497. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L198" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  498. </dd>
  499. </div>
  500. </div>
  501. <div id="withData-templates-all">
  502. <div id="withData.t,Selector[T],,untyped,untyped,untyped">
  503. <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>
  504. <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>
  505. <dd>
  506. <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>
  507. <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>
  508. <span class="Comment"># block is executed only if `fd` registered in selector `s`.</span>
  509. <span class="Identifier">value</span><span class="Operator">.</span><span class="Identifier">uid</span> <span class="Operator">=</span> <span class="DecNumber">1000</span>
  510. <span class="Keyword">do</span><span class="Punctuation">:</span>
  511. <span class="Comment"># block is executed if `fd` not registered in selector `s`.</span>
  512. <span class="Keyword">raise</span></pre></p>
  513. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L214" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  514. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L214" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  515. </dd>
  516. </div>
  517. <div id="withData.t,Selector[T],,untyped,untyped">
  518. <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>
  519. <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>
  520. <dd>
  521. <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>
  522. <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>
  523. <span class="Comment"># block is executed only if `fd` registered in selector `s`</span>
  524. <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>
  525. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/selectors.nim#L202" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  526. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/selectors.nim#L202" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  527. </dd>
  528. </div>
  529. </div>
  530. </dl>
  531. </div>
  532. </div>
  533. </div>
  534. <div class="twelve-columns footer">
  535. <span class="nim-sprite"></span>
  536. <br>
  537. <small style="color: var(--hint);">Made with Nim. Generated: 2024-12-25 13:28:11 UTC</small>
  538. </div>
  539. </div>
  540. </div>
  541. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  542. </body>
  543. </html>