asyncfutures.html 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  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/asyncfutures</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/asyncfutures</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="#Future" title="Future[T] = ref object of FutureBase
  57. ## Stored value">Future</a></li>
  58. <li><a class="reference" href="#FutureBase" title="FutureBase = ref object of RootObj
  59. error*: ref Exception ## Stored exception
  60. errorStackTrace*: string
  61. when not defined(release) or defined(futureLogging):
  62. ## For debugging purposes only.">FutureBase</a></li>
  63. <li><a class="reference" href="#FutureError" title="FutureError = object of Defect
  64. cause*: FutureBase">FutureError</a></li>
  65. <li><a class="reference" href="#FutureVar" title="FutureVar[T] = distinct Future[T]">FutureVar</a></li>
  66. </ul>
  67. </details>
  68. </li>
  69. <li>
  70. <details open>
  71. <summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
  72. <ul class="simple simple-toc-section">
  73. <li><a class="reference" href="#isFutureLoggingEnabled" title="isFutureLoggingEnabled = false">isFutureLoggingEnabled</a></li>
  74. <li><a class="reference" href="#NimAsyncContinueSuffix" title="NimAsyncContinueSuffix = &quot;NimAsyncContinue&quot;">NimAsyncContinueSuffix</a></li>
  75. </ul>
  76. </details>
  77. </li>
  78. <li>
  79. <details open>
  80. <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
  81. <ul class="simple simple-toc-section">
  82. <ul class="simple nested-toc-section">$
  83. <li><a class="reference" href="#%24%2Cseq%5BStackTraceEntry%5D" title="`$`(stackTraceEntries: seq[StackTraceEntry]): string">`$`(stackTraceEntries: seq[StackTraceEntry]): string</a></li>
  84. </ul>
  85. <ul class="simple nested-toc-section">addCallback
  86. <li><a class="reference" href="#addCallback%2CFutureBase%2Cproc%29" title="addCallback(future: FutureBase; cb: proc () {.closure, gcsafe.})">addCallback(future: FutureBase; cb: proc () {.closure, gcsafe.})</a></li>
  87. <li><a class="reference" href="#addCallback%2CFuture%5BT%5D%2Cproc%28Future%5BT%5D%29" title="addCallback[T](future: Future[T];
  88. cb: proc (future: Future[T]) {.closure, gcsafe.})">addCallback[T](future: Future[T];
  89. cb: proc (future: Future[T]) {.closure, gcsafe.})</a></li>
  90. </ul>
  91. <ul class="simple nested-toc-section">all
  92. <li><a class="reference" href="#all%2Cvarargs%5BFuture%5BT%5D%5D" title="all[T](futs: varargs[Future[T]]): auto">all[T](futs: varargs[Future[T]]): auto</a></li>
  93. </ul>
  94. <ul class="simple nested-toc-section">and
  95. <li><a class="reference" href="#and%2CFuture%5BT%5D%2CFuture%5BY%5D" title="`and`[T, Y](fut1: Future[T]; fut2: Future[Y]): Future[void]">`and`[T, Y](fut1: Future[T]; fut2: Future[Y]): Future[void]</a></li>
  96. </ul>
  97. <ul class="simple nested-toc-section">asyncCheck
  98. <li><a class="reference" href="#asyncCheck%2CFuture%5BT%5D" title="asyncCheck[T](future: Future[T])">asyncCheck[T](future: Future[T])</a></li>
  99. </ul>
  100. <ul class="simple nested-toc-section">callback=
  101. <li><a class="reference" href="#callback%3D%2CFutureBase%2Cproc%29" title="callback=(future: FutureBase; cb: proc () {.closure, gcsafe.})">callback=(future: FutureBase; cb: proc () {.closure, gcsafe.})</a></li>
  102. <li><a class="reference" href="#callback%3D%2CFuture%5BT%5D%2Cproc%28Future%5BT%5D%29" title="callback=[T](future: Future[T]; cb: proc (future: Future[T]) {.closure, gcsafe.})">callback=[T](future: Future[T]; cb: proc (future: Future[T]) {.closure, gcsafe.})</a></li>
  103. </ul>
  104. <ul class="simple nested-toc-section">callSoon
  105. <li><a class="reference" href="#callSoon%2Cproc%29" title="callSoon(cbproc: proc () {.gcsafe.})">callSoon(cbproc: proc () {.gcsafe.})</a></li>
  106. </ul>
  107. <ul class="simple nested-toc-section">clean
  108. <li><a class="reference" href="#clean%2CFutureVar%5BT%5D" title="clean[T](future: FutureVar[T])">clean[T](future: FutureVar[T])</a></li>
  109. </ul>
  110. <ul class="simple nested-toc-section">clearCallbacks
  111. <li><a class="reference" href="#clearCallbacks%2CFutureBase" title="clearCallbacks(future: FutureBase)">clearCallbacks(future: FutureBase)</a></li>
  112. </ul>
  113. <ul class="simple nested-toc-section">complete
  114. <li><a class="reference" href="#complete%2CFuture%5Bvoid%5D" title="complete(future: Future[void]; val = Future[void].default)">complete(future: Future[void]; val = Future[void].default)</a></li>
  115. <li><a class="reference" href="#complete%2CFuture%5BT%5D%2CsinkT" title="complete[T](future: Future[T]; val: sink T)">complete[T](future: Future[T]; val: sink T)</a></li>
  116. <li><a class="reference" href="#complete%2CFutureVar%5BT%5D" title="complete[T](future: FutureVar[T])">complete[T](future: FutureVar[T])</a></li>
  117. <li><a class="reference" href="#complete%2CFutureVar%5BT%5D%2CsinkT" title="complete[T](future: FutureVar[T]; val: sink T)">complete[T](future: FutureVar[T]; val: sink T)</a></li>
  118. </ul>
  119. <ul class="simple nested-toc-section">fail
  120. <li><a class="reference" href="#fail%2CFuture%5BT%5D%2Cref.Exception" title="fail[T](future: Future[T]; error: ref Exception)">fail[T](future: Future[T]; error: ref Exception)</a></li>
  121. </ul>
  122. <ul class="simple nested-toc-section">failed
  123. <li><a class="reference" href="#failed%2CFutureBase" title="failed(future: FutureBase): bool">failed(future: FutureBase): bool</a></li>
  124. </ul>
  125. <ul class="simple nested-toc-section">finished
  126. <li><a class="reference" href="#finished" title="finished(future: FutureBase | FutureVar): bool">finished(future: FutureBase | FutureVar): bool</a></li>
  127. </ul>
  128. <ul class="simple nested-toc-section">getCallSoonProc
  129. <li><a class="reference" href="#getCallSoonProc" title="getCallSoonProc(): (proc (cbproc: proc ()) {.gcsafe.})">getCallSoonProc(): (proc (cbproc: proc ()) {.gcsafe.})</a></li>
  130. </ul>
  131. <ul class="simple nested-toc-section">mget
  132. <li><a class="reference" href="#mget%2CFutureVar%5BT%5D" title="mget[T](future: FutureVar[T]): var T">mget[T](future: FutureVar[T]): var T</a></li>
  133. </ul>
  134. <ul class="simple nested-toc-section">newFuture
  135. <li><a class="reference" href="#newFuture%2Cstring" title="newFuture[T](fromProc: string = &quot;unspecified&quot;): owned(Future[T])">newFuture[T](fromProc: string = &quot;unspecified&quot;): owned(Future[T])</a></li>
  136. </ul>
  137. <ul class="simple nested-toc-section">newFutureVar
  138. <li><a class="reference" href="#newFutureVar%2Cstring" title="newFutureVar[T](fromProc = &quot;unspecified&quot;): owned(FutureVar[T])">newFutureVar[T](fromProc = &quot;unspecified&quot;): owned(FutureVar[T])</a></li>
  139. </ul>
  140. <ul class="simple nested-toc-section">or
  141. <li><a class="reference" href="#or%2CFuture%5BT%5D%2CFuture%5BY%5D" title="`or`[T, Y](fut1: Future[T]; fut2: Future[Y]): Future[void]">`or`[T, Y](fut1: Future[T]; fut2: Future[Y]): Future[void]</a></li>
  142. </ul>
  143. <ul class="simple nested-toc-section">read
  144. <li><a class="reference" href="#read_2" title="read(future: Future[void] | FutureVar[void])">read(future: Future[void] | FutureVar[void])</a></li>
  145. <li><a class="reference" href="#read" title="read[T](future: Future[T] | FutureVar[T]): lent T">read[T](future: Future[T] | FutureVar[T]): lent T</a></li>
  146. </ul>
  147. <ul class="simple nested-toc-section">readError
  148. <li><a class="reference" href="#readError%2CFuture%5BT%5D" title="readError[T](future: Future[T]): ref Exception">readError[T](future: Future[T]): ref Exception</a></li>
  149. </ul>
  150. <ul class="simple nested-toc-section">setCallSoonProc
  151. <li><a class="reference" href="#setCallSoonProc" title="setCallSoonProc(p: (proc (cbproc: proc ()) {.gcsafe.}))">setCallSoonProc(p: (proc (cbproc: proc ()) {.gcsafe.}))</a></li>
  152. </ul>
  153. </ul>
  154. </details>
  155. </li>
  156. </ul>
  157. </div>
  158. <div class="nine columns" id="content">
  159. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  160. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  161. <div id="tocRoot"></div>
  162. <p class="module-desc"></p>
  163. <div class="section" id="6">
  164. <h1><a class="toc-backref" href="#6">Imports</a></h1>
  165. <dl class="item">
  166. <a class="reference external" href="os.html">os</a>, <a class="reference external" href="sets.html">sets</a>, <a class="reference external" href="tables.html">tables</a>, <a class="reference external" href="strutils.html">strutils</a>, <a class="reference external" href="times.html">times</a>, <a class="reference external" href="heapqueue.html">heapqueue</a>, <a class="reference external" href="options.html">options</a>, <a class="reference external" href="deques.html">deques</a>, <a class="reference external" href="cstrutils.html">cstrutils</a>, <a class="reference external" href="typetraits.html">typetraits</a>, <a class="reference external" href="stacktraces.html">stacktraces</a>, <a class="reference external" href="objectdollar.html">objectdollar</a>, <a class="reference external" href="assertions.html">assertions</a>
  167. </dl>
  168. </div>
  169. <div class="section" id="7">
  170. <h1><a class="toc-backref" href="#7">Types</a></h1>
  171. <dl class="item">
  172. <div id="Future">
  173. <dt><pre><a href="asyncfutures.html#Future"><span class="Identifier">Future</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> <span class="Keyword">of</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a>
  174. <span class="Comment">## Stored value</span></pre></dt>
  175. <dd>
  176. Typed future.
  177. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L37" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  178. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L37" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  179. </dd>
  180. </div>
  181. <div id="FutureBase">
  182. <dt><pre><a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="system.html#RootObj"><span class="Identifier">RootObj</span></a>
  183. <span class="Identifier">error</span><span class="Operator">*</span><span class="Other">:</span> <span class="Keyword">ref</span> <a href="system.html#Exception"><span class="Identifier">Exception</span></a> <span class="Comment">## Stored exception</span>
  184. <span class="Identifier">errorStackTrace</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a>
  185. <span class="Keyword">when</span> <span class="Keyword">not</span> <span class="Identifier">defined</span><span class="Other">(</span><span class="Identifier">release</span><span class="Other">)</span> <span class="Keyword">or</span> <span class="Identifier">defined</span><span class="Other">(</span><span class="Identifier">futureLogging</span><span class="Other">)</span><span class="Other">:</span>
  186. <span class="Comment">## For debugging purposes only.</span></pre></dt>
  187. <dd>
  188. Untyped future.
  189. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L26" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  190. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L26" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  191. </dd>
  192. </div>
  193. <div id="FutureError">
  194. <dt><pre><a href="asyncfutures.html#FutureError"><span class="Identifier">FutureError</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="system.html#Defect"><span class="Identifier">Defect</span></a>
  195. <span class="Identifier">cause</span><span class="Operator">*</span><span class="Other">:</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a></pre></dt>
  196. <dd>
  197. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L42" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  198. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L42" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  199. </dd>
  200. </div>
  201. <div id="FutureVar">
  202. <dt><pre><a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Other">=</span> <span class="Keyword">distinct</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span></pre></dt>
  203. <dd>
  204. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L40" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  205. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L40" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  206. </dd>
  207. </div>
  208. </dl>
  209. </div>
  210. <div class="section" id="10">
  211. <h1><a class="toc-backref" href="#10">Consts</a></h1>
  212. <dl class="item">
  213. <div id="isFutureLoggingEnabled">
  214. <dt><pre><a href="asyncfutures.html#isFutureLoggingEnabled"><span class="Identifier">isFutureLoggingEnabled</span></a> <span class="Other">=</span> <span class="DecNumber">false</span></pre></dt>
  215. <dd>
  216. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L48" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  217. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L48" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  218. </dd>
  219. </div>
  220. <div id="NimAsyncContinueSuffix">
  221. <dt><pre><a href="asyncfutures.html#NimAsyncContinueSuffix"><span class="Identifier">NimAsyncContinueSuffix</span></a> <span class="Other">=</span> <span class="StringLit">&quot;NimAsyncContinue&quot;</span></pre></dt>
  222. <dd>
  223. For internal usage. Do not use.
  224. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L51" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  225. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L51" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  226. </dd>
  227. </div>
  228. </dl>
  229. </div>
  230. <div class="section" id="12">
  231. <h1><a class="toc-backref" href="#12">Procs</a></h1>
  232. <dl class="item">
  233. <div id="$-procs-all">
  234. <div id="$,seq[StackTraceEntry]">
  235. <dt><pre><span class="Keyword">proc</span> <a href="#%24%2Cseq%5BStackTraceEntry%5D"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">stackTraceEntries</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="system.html#StackTraceEntry"><span class="Identifier">StackTraceEntry</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.
  236. <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="Identifier">ValueError</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>
  237. <dd>
  238. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L314" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  239. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L314" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  240. </dd>
  241. </div>
  242. </div>
  243. <div id="addCallback-procs-all">
  244. <div id="addCallback,FutureBase,proc)">
  245. <dt><pre><span class="Keyword">proc</span> <a href="#addCallback%2CFutureBase%2Cproc%29"><span class="Identifier">addCallback</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a><span class="Other">;</span> <span class="Identifier">cb</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Other">)</span> {.<span class="Identifier">closure</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span> {.
  246. <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="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</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>
  247. <dd>
  248. <p>Adds the callbacks proc to be called when the future completes.</p>
  249. <p>If future has already completed then <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> will be called immediately.</p>
  250. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L249" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  251. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L249" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  252. </dd>
  253. </div>
  254. <div id="addCallback,Future[T],proc(Future[T])">
  255. <dt><pre><span class="Keyword">proc</span> <a href="#addCallback%2CFuture%5BT%5D%2Cproc%28Future%5BT%5D%29"><span class="Identifier">addCallback</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span>
  256. <span class="Identifier">cb</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">closure</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span></pre></dt>
  257. <dd>
  258. <p>Adds the callbacks proc to be called when the future completes.</p>
  259. <p>If future has already completed then <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> will be called immediately.</p>
  260. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L259" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  261. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L259" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  262. </dd>
  263. </div>
  264. </div>
  265. <div id="all-procs-all">
  266. <div id="all,varargs[Future[T]]">
  267. <dt><pre><span class="Keyword">proc</span> <a href="#all%2Cvarargs%5BFuture%5BT%5D%5D"><span class="Identifier">all</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">futs</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</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="system.html#auto"><span class="Identifier">auto</span></a></pre></dt>
  268. <dd>
  269. <p>Returns a future which will complete once all futures in <tt class="docutils literal"><span class="pre"><span class="Identifier">futs</span></span></tt> complete. If the argument is empty, the returned future completes immediately.</p>
  270. <p>If the awaited futures are not <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span></span></tt>, the returned future will hold the values of all awaited futures in a sequence.</p>
  271. <p>If the awaited futures <em>are</em> <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span></span></tt>, this proc returns <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span></span></tt>.</p>
  272. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L459" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  273. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L459" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  274. </dd>
  275. </div>
  276. </div>
  277. <div id="and-procs-all">
  278. <div id="and,Future[T],Future[Y]">
  279. <dt><pre><span class="Keyword">proc</span> <a href="#and%2CFuture%5BT%5D%2CFuture%5BY%5D"><span class="Identifier">`and`</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">,</span> <span class="Identifier">Y</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">fut1</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fut2</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">Y</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span></pre></dt>
  280. <dd>
  281. Returns a future which will complete once both <tt class="docutils literal"><span class="pre"><span class="Identifier">fut1</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">fut2</span></span></tt> complete.
  282. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L431" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  283. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L431" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  284. </dd>
  285. </div>
  286. </div>
  287. <div id="asyncCheck-procs-all">
  288. <div id="asyncCheck,Future[T]">
  289. <dt><pre><span class="Keyword">proc</span> <a href="#asyncCheck%2CFuture%5BT%5D"><span class="Identifier">asyncCheck</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
  290. <dd>
  291. <p>Sets a callback on <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> which raises an exception if the future finished with an error.</p>
  292. <p>This should be used instead of <tt class="docutils literal"><span class="pre"><span class="Keyword">discard</span></span></tt> to discard void futures, or use <tt class="docutils literal"><span class="pre"><span class="Identifier">waitFor</span></span></tt> if you need to wait for the future's completion.</p>
  293. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L416" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  294. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L416" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  295. </dd>
  296. </div>
  297. </div>
  298. <div id="callback=-procs-all">
  299. <div id="callback=,FutureBase,proc)">
  300. <dt><pre><span class="Keyword">proc</span> <a href="#callback%3D%2CFutureBase%2Cproc%29"><span class="Identifier">callback=</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a><span class="Other">;</span> <span class="Identifier">cb</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Other">)</span> {.<span class="Identifier">closure</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span> {.
  301. <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="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</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>
  302. <dd>
  303. <p>Clears the list of callbacks and sets the callback proc to be called when the future completes.</p>
  304. <p>If future has already completed then <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> will be called immediately.</p>
  305. <p>It's recommended to use <tt class="docutils literal"><span class="pre"><span class="Identifier">addCallback</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">then</span></span></tt> instead.</p>
  306. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L269" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  307. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L269" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  308. </dd>
  309. </div>
  310. <div id="callback=,Future[T],proc(Future[T])">
  311. <dt><pre><span class="Keyword">proc</span> <a href="#callback%3D%2CFuture%5BT%5D%2Cproc%28Future%5BT%5D%29"><span class="Identifier">callback=</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span>
  312. <span class="Identifier">cb</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">closure</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span></pre></dt>
  313. <dd>
  314. <p>Sets the callback proc to be called when the future completes.</p>
  315. <p>If future has already completed then <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> will be called immediately.</p>
  316. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L278" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  317. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L278" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  318. </dd>
  319. </div>
  320. </div>
  321. <div id="callSoon-procs-all">
  322. <div id="callSoon,proc)">
  323. <dt><pre><span class="Keyword">proc</span> <a href="#callSoon%2Cproc%29"><span class="Identifier">callSoon</span></a><span class="Other">(</span><span class="Identifier">cbproc</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<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="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
  324. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</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>
  325. <dd>
  326. <p>Call <tt class="docutils literal"><span class="pre"><span class="Identifier">cbproc</span></span></tt> &quot;soon&quot;.</p>
  327. <p>If async dispatcher is running, <tt class="docutils literal"><span class="pre"><span class="Identifier">cbproc</span></span></tt> will be executed during next dispatcher tick.</p>
  328. <p>If async dispatcher is not running, <tt class="docutils literal"><span class="pre"><span class="Identifier">cbproc</span></span></tt> will be executed immediately.</p>
  329. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L100" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  330. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L100" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  331. </dd>
  332. </div>
  333. </div>
  334. <div id="clean-procs-all">
  335. <div id="clean,FutureVar[T]">
  336. <dt><pre><span class="Keyword">proc</span> <a href="#clean%2CFutureVar%5BT%5D"><span class="Identifier">clean</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
  337. <dd>
  338. Resets the <tt class="docutils literal"><span class="pre"><span class="Identifier">finished</span></span></tt> status of <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt>.
  339. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L139" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  340. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L139" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  341. </dd>
  342. </div>
  343. </div>
  344. <div id="clearCallbacks-procs-all">
  345. <div id="clearCallbacks,FutureBase">
  346. <dt><pre><span class="Keyword">proc</span> <a href="#clearCallbacks%2CFutureBase"><span class="Identifier">clearCallbacks</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</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>
  347. <dd>
  348. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L245" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  349. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L245" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  350. </dd>
  351. </div>
  352. </div>
  353. <div id="complete-procs-all">
  354. <div id="complete,Future[void]">
  355. <dt><pre><span class="Keyword">proc</span> <a href="#complete%2CFuture%5Bvoid%5D"><span class="Identifier">complete</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">val</span> <span class="Other">=</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">.</span><span class="Identifier">default</span><span class="Other">)</span> {.
  356. <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="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</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>
  357. <dd>
  358. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L210" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  359. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L210" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  360. </dd>
  361. </div>
  362. <div id="complete,Future[T],sinkT">
  363. <dt><pre><span class="Keyword">proc</span> <a href="#complete%2CFuture%5BT%5D%2CsinkT"><span class="Identifier">complete</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <span class="Identifier">T</span><span class="Other">)</span></pre></dt>
  364. <dd>
  365. Completes <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> with value <tt class="docutils literal"><span class="pre"><span class="Identifier">val</span></span></tt>.
  366. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L206" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  367. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L206" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  368. </dd>
  369. </div>
  370. <div id="complete,FutureVar[T]">
  371. <dt><pre><span class="Keyword">proc</span> <a href="#complete%2CFutureVar%5BT%5D"><span class="Identifier">complete</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
  372. <dd>
  373. Completes a <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureVar</span></span></tt>.
  374. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L213" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  375. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L213" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  376. </dd>
  377. </div>
  378. <div id="complete,FutureVar[T],sinkT">
  379. <dt><pre><span class="Keyword">proc</span> <a href="#complete%2CFutureVar%5BT%5D%2CsinkT"><span class="Identifier">complete</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <span class="Identifier">T</span><span class="Other">)</span></pre></dt>
  380. <dd>
  381. <p>Completes a <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureVar</span></span></tt> with value <tt class="docutils literal"><span class="pre"><span class="Identifier">val</span></span></tt>.</p>
  382. <p>Any previously stored value will be overwritten.</p>
  383. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L222" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  384. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L222" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  385. </dd>
  386. </div>
  387. </div>
  388. <div id="fail-procs-all">
  389. <div id="fail,Future[T],ref.Exception">
  390. <dt><pre><span class="Keyword">proc</span> <a href="#fail%2CFuture%5BT%5D%2Cref.Exception"><span class="Identifier">fail</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">error</span><span class="Other">:</span> <span class="Keyword">ref</span> <a href="system.html#Exception"><span class="Identifier">Exception</span></a><span class="Other">)</span></pre></dt>
  391. <dd>
  392. Completes <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> with <tt class="docutils literal"><span class="pre"><span class="Identifier">error</span></span></tt>.
  393. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L234" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  394. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L234" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  395. </dd>
  396. </div>
  397. </div>
  398. <div id="failed-procs-all">
  399. <div id="failed,FutureBase">
  400. <dt><pre><span class="Keyword">proc</span> <a href="#failed%2CFutureBase"><span class="Identifier">failed</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</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>
  401. <dd>
  402. Determines whether <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> completed with an error.
  403. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L412" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  404. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L412" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  405. </dd>
  406. </div>
  407. </div>
  408. <div id="finished-procs-all">
  409. <div id="finished">
  410. <dt><pre><span class="Keyword">proc</span> <a href="#finished"><span class="Identifier">finished</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a> <span class="Operator">|</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a></pre></dt>
  411. <dd>
  412. <p>Determines whether <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> has completed.</p>
  413. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">True</span></span></tt> may indicate an error or a value. Use <tt class="docutils literal"><span class="pre"><span class="Identifier">failed</span></span></tt> to distinguish.</p>
  414. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L403" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  415. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L403" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  416. </dd>
  417. </div>
  418. </div>
  419. <div id="getCallSoonProc-procs-all">
  420. <div id="getCallSoonProc">
  421. <dt><pre><span class="Keyword">proc</span> <a href="#getCallSoonProc"><span class="Identifier">getCallSoonProc</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Other">(</span><span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">cbproc</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Other">)</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<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>
  422. <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>
  423. <dd>
  424. Get current implementation of <tt class="docutils literal"><span class="pre"><span class="Identifier">callSoon</span></span></tt>.
  425. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L92" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  426. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L92" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  427. </dd>
  428. </div>
  429. </div>
  430. <div id="mget-procs-all">
  431. <div id="mget,FutureVar[T]">
  432. <dt><pre><span class="Keyword">proc</span> <a href="#mget%2CFutureVar%5BT%5D"><span class="Identifier">mget</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</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="Keyword">var</span> <span class="Identifier">T</span></pre></dt>
  433. <dd>
  434. <p>Returns a mutable value stored in <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt>.</p>
  435. <p>Unlike <tt class="docutils literal"><span class="pre"><span class="Identifier">read</span></span></tt>, this function will not raise an exception if the Future has not been finished.</p>
  436. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L396" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  437. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L396" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  438. </dd>
  439. </div>
  440. </div>
  441. <div id="newFuture-procs-all">
  442. <div id="newFuture,string">
  443. <dt><pre><span class="Keyword">proc</span> <a href="#newFuture%2Cstring"><span class="Identifier">newFuture</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">fromProc</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Other">=</span> <span class="StringLit">&quot;unspecified&quot;</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
  444. <dd>
  445. <p>Creates a new future.</p>
  446. <p>Specifying <tt class="docutils literal"><span class="pre"><span class="Identifier">fromProc</span></span></tt>, which is a string specifying the name of the proc that this future belongs to, is a good habit as it helps with debugging.</p>
  447. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L121" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  448. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L121" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  449. </dd>
  450. </div>
  451. </div>
  452. <div id="newFutureVar-procs-all">
  453. <div id="newFutureVar,string">
  454. <dt><pre><span class="Keyword">proc</span> <a href="#newFutureVar%2Cstring"><span class="Identifier">newFutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">fromProc</span> <span class="Other">=</span> <span class="StringLit">&quot;unspecified&quot;</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
  455. <dd>
  456. <p>Create a new <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureVar</span></span></tt>. This Future type is ideally suited for situations where you want to avoid unnecessary allocations of Futures.</p>
  457. <p>Specifying <tt class="docutils literal"><span class="pre"><span class="Identifier">fromProc</span></span></tt>, which is a string specifying the name of the proc that this future belongs to, is a good habit as it helps with debugging.</p>
  458. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L129" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  459. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L129" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  460. </dd>
  461. </div>
  462. </div>
  463. <div id="or-procs-all">
  464. <div id="or,Future[T],Future[Y]">
  465. <dt><pre><span class="Keyword">proc</span> <a href="#or%2CFuture%5BT%5D%2CFuture%5BY%5D"><span class="Identifier">`or`</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">,</span> <span class="Identifier">Y</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">fut1</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fut2</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">Y</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span></pre></dt>
  466. <dd>
  467. Returns a future which will complete once either <tt class="docutils literal"><span class="pre"><span class="Identifier">fut1</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">fut2</span></span></tt> complete.
  468. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L447" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  469. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L447" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  470. </dd>
  471. </div>
  472. </div>
  473. <div id="read-procs-all">
  474. <div id="read_2">
  475. <dt><pre><span class="Keyword">proc</span> <a href="#read_2"><span class="Identifier">read</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span> <span class="Operator">|</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">)</span></pre></dt>
  476. <dd>
  477. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L384" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  478. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L384" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  479. </dd>
  480. </div>
  481. <div id="read">
  482. <dt><pre><span class="Keyword">proc</span> <a href="#read"><span class="Identifier">read</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Operator">|</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</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#lent"><span class="Identifier">lent</span></a> <span class="Identifier">T</span></pre></dt>
  483. <dd>
  484. <p>Retrieves the value of <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt>. Future must be finished otherwise this function will fail with a <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> exception.</p>
  485. <p>If the result of the future is an error then that error will be raised.</p>
  486. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L377" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  487. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L377" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  488. </dd>
  489. </div>
  490. </div>
  491. <div id="readError-procs-all">
  492. <div id="readError,Future[T]">
  493. <dt><pre><span class="Keyword">proc</span> <a href="#readError%2CFuture%5BT%5D"><span class="Identifier">readError</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</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="Keyword">ref</span> <a href="system.html#Exception"><span class="Identifier">Exception</span></a></pre></dt>
  494. <dd>
  495. <p>Retrieves the exception stored in <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt>.</p>
  496. <p>An <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> exception will be thrown if no exception exists in the specified Future.</p>
  497. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L387" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  498. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L387" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  499. </dd>
  500. </div>
  501. </div>
  502. <div id="setCallSoonProc-procs-all">
  503. <div id="setCallSoonProc">
  504. <dt><pre><span class="Keyword">proc</span> <a href="#setCallSoonProc"><span class="Identifier">setCallSoonProc</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <span class="Other">(</span><span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">cbproc</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Other">)</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span><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>
  505. <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>
  506. <dd>
  507. Change current implementation of <tt class="docutils literal"><span class="pre"><span class="Identifier">callSoon</span></span></tt>. This is normally called when dispatcher from <tt class="docutils literal"><span class="pre"><span class="Identifier">asyncdispatcher</span></span></tt> is initialized.
  508. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L96" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  509. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L96" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  510. </dd>
  511. </div>
  512. </div>
  513. </dl>
  514. </div>
  515. </div>
  516. </div>
  517. <div class="twelve-columns footer">
  518. <span class="nim-sprite"></span>
  519. <br>
  520. <small style="color: var(--hint);">Made with Nim. Generated: 2024-12-25 13:27:59 UTC</small>
  521. </div>
  522. </div>
  523. </div>
  524. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  525. </body>
  526. </html>