asyncstreams.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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/asyncstreams</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/asyncstreams</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="#FutureStream" title="FutureStream[T] = ref object
  57. error*: ref Exception">FutureStream</a></li>
  58. </ul>
  59. </details>
  60. </li>
  61. <li>
  62. <details open>
  63. <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
  64. <ul class="simple simple-toc-section">
  65. <ul class="simple nested-toc-section">callback=
  66. <li><a class="reference" href="#callback%3D%2CFutureStream%5BT%5D%2Cproc%28FutureStream%5BT%5D%29" title="callback=[T](future: FutureStream[T];
  67. cb: proc (future: FutureStream[T]) {.closure, gcsafe.})">callback=[T](future: FutureStream[T];
  68. cb: proc (future: FutureStream[T]) {.closure, gcsafe.})</a></li>
  69. </ul>
  70. <ul class="simple nested-toc-section">complete
  71. <li><a class="reference" href="#complete%2CFutureStream%5BT%5D" title="complete[T](future: FutureStream[T])">complete[T](future: FutureStream[T])</a></li>
  72. </ul>
  73. <ul class="simple nested-toc-section">fail
  74. <li><a class="reference" href="#fail%2CFutureStream%5BT%5D%2Cref.Exception" title="fail[T](future: FutureStream[T]; error: ref Exception)">fail[T](future: FutureStream[T]; error: ref Exception)</a></li>
  75. </ul>
  76. <ul class="simple nested-toc-section">failed
  77. <li><a class="reference" href="#failed%2CFutureStream%5BT%5D" title="failed[T](future: FutureStream[T]): bool">failed[T](future: FutureStream[T]): bool</a></li>
  78. </ul>
  79. <ul class="simple nested-toc-section">finished
  80. <li><a class="reference" href="#finished%2CFutureStream%5BT%5D" title="finished[T](future: FutureStream[T]): bool">finished[T](future: FutureStream[T]): bool</a></li>
  81. </ul>
  82. <ul class="simple nested-toc-section">len
  83. <li><a class="reference" href="#len%2CFutureStream%5BT%5D" title="len[T](future: FutureStream[T]): int">len[T](future: FutureStream[T]): int</a></li>
  84. </ul>
  85. <ul class="simple nested-toc-section">newFutureStream
  86. <li><a class="reference" href="#newFutureStream%2Cstring" title="newFutureStream[T](fromProc = &quot;unspecified&quot;): FutureStream[T]">newFutureStream[T](fromProc = &quot;unspecified&quot;): FutureStream[T]</a></li>
  87. </ul>
  88. <ul class="simple nested-toc-section">read
  89. <li><a class="reference" href="#read%2CFutureStream%5BT%5D" title="read[T](future: FutureStream[T]): owned(Future[(bool, T)])">read[T](future: FutureStream[T]): owned(Future[(bool, T)])</a></li>
  90. </ul>
  91. <ul class="simple nested-toc-section">write
  92. <li><a class="reference" href="#write%2CFutureStream%5BT%5D%2CT" title="write[T](future: FutureStream[T]; value: T): Future[void]">write[T](future: FutureStream[T]; value: T): Future[void]</a></li>
  93. </ul>
  94. </ul>
  95. </details>
  96. </li>
  97. </ul>
  98. </div>
  99. <div class="nine columns" id="content">
  100. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  101. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  102. <div id="tocRoot"></div>
  103. <p class="module-desc">Unstable API.</p>
  104. <div class="section" id="6">
  105. <h1><a class="toc-backref" href="#6">Imports</a></h1>
  106. <dl class="item">
  107. <a class="reference external" href="asyncfutures.html">asyncfutures</a>, <a class="reference external" href="assertions.html">assertions</a>, <a class="reference external" href="deques.html">deques</a>
  108. </dl>
  109. </div>
  110. <div class="section" id="7">
  111. <h1><a class="toc-backref" href="#7">Types</a></h1>
  112. <dl class="item">
  113. <div id="FutureStream">
  114. <dt><pre><a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</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>
  115. <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></pre></dt>
  116. <dd>
  117. Special future that acts as a queue. Its API is still experimental and so is subject to change.
  118. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L20" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  119. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L20" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  120. </dd>
  121. </div>
  122. </dl>
  123. </div>
  124. <div class="section" id="12">
  125. <h1><a class="toc-backref" href="#12">Procs</a></h1>
  126. <dl class="item">
  127. <div id="callback=-procs-all">
  128. <div id="callback=,FutureStream[T],proc(FutureStream[T])">
  129. <dt><pre><span class="Keyword">proc</span> <a href="#callback%3D%2CFutureStream%5BT%5D%2Cproc%28FutureStream%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="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span>
  130. <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="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</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>
  131. <dd>
  132. <p>Sets the callback proc to be called when data was placed inside the future stream.</p>
  133. <p>The callback is also called when the future is completed. So you should use <tt class="docutils literal"><span class="pre"><span class="Identifier">finished</span></span></tt> to check whether data is available.</p>
  134. <p>If the future stream already has data or is finished then <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> will be called immediately.</p>
  135. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L60" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  136. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L60" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  137. </dd>
  138. </div>
  139. </div>
  140. <div id="complete-procs-all">
  141. <div id="complete,FutureStream[T]">
  142. <dt><pre><span class="Keyword">proc</span> <a href="#complete%2CFutureStream%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="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
  143. <dd>
  144. Completes a <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureStream</span></span></tt> signalling the end of data.
  145. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L45" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  146. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L45" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  147. </dd>
  148. </div>
  149. </div>
  150. <div id="fail-procs-all">
  151. <div id="fail,FutureStream[T],ref.Exception">
  152. <dt><pre><span class="Keyword">proc</span> <a href="#fail%2CFutureStream%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="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</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>
  153. <dd>
  154. 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>.
  155. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L52" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  156. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L52" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  157. </dd>
  158. </div>
  159. </div>
  160. <div id="failed-procs-all">
  161. <div id="failed,FutureStream[T]">
  162. <dt><pre><span class="Keyword">proc</span> <a href="#failed%2CFutureStream%5BT%5D"><span class="Identifier">failed</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="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</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>
  163. <dd>
  164. Determines whether <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> completed with an error.
  165. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L81" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  166. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L81" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  167. </dd>
  168. </div>
  169. </div>
  170. <div id="finished-procs-all">
  171. <div id="finished,FutureStream[T]">
  172. <dt><pre><span class="Keyword">proc</span> <a href="#finished%2CFutureStream%5BT%5D"><span class="Identifier">finished</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="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</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>
  173. <dd>
  174. Check if a <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureStream</span></span></tt> is finished. <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt> value means that no more data will be placed inside the stream <em>and</em> that there is no data waiting to be retrieved.
  175. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L75" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  176. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L75" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  177. </dd>
  178. </div>
  179. </div>
  180. <div id="len-procs-all">
  181. <div id="len,FutureStream[T]">
  182. <dt><pre><span class="Keyword">proc</span> <a href="#len%2CFutureStream%5BT%5D"><span class="Identifier">len</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="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</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>
  183. <dd>
  184. Returns the amount of data pieces inside the stream.
  185. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L145" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  186. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L145" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  187. </dd>
  188. </div>
  189. </div>
  190. <div id="newFutureStream-procs-all">
  191. <div id="newFutureStream,string">
  192. <dt><pre><span class="Keyword">proc</span> <a href="#newFutureStream%2Cstring"><span class="Identifier">newFutureStream</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> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span></pre></dt>
  193. <dd>
  194. Create a new <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureStream</span></span></tt>. This future's callback is activated when two events occur:<ul class="simple"><li>New data is written into the future stream.</li>
  195. <li>The future stream is completed (this means that no more data will be written).</li>
  196. </ul>
  197. <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>
  198. <p><strong>Note:</strong> The API of FutureStream is still new and so has a higher likelihood of changing in the future.</p>
  199. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L29" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  200. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L29" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  201. </dd>
  202. </div>
  203. </div>
  204. <div id="read-procs-all">
  205. <div id="read,FutureStream[T]">
  206. <dt><pre><span class="Keyword">proc</span> <a href="#read%2CFutureStream%5BT%5D"><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="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</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="Identifier">owned</span><span class="Other">(</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Other">(</span><a href="system.html#bool"><span class="Identifier">bool</span></a><span class="Other">,</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
  207. <dd>
  208. <p>Returns a future that will complete when the <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureStream</span></span></tt> has data placed into it. The future will be completed with the oldest value stored inside the stream. The return value will also determine whether data was retrieved, <tt class="docutils literal"><span class="pre"><span class="Identifier">false</span></span></tt> means that the future stream was completed and no data was retrieved.</p>
  209. <p>This function will remove the data that was returned from the underlying <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureStream</span></span></tt>.</p>
  210. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L100" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  211. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L100" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  212. </dd>
  213. </div>
  214. </div>
  215. <div id="write-procs-all">
  216. <div id="write,FutureStream[T],T">
  217. <dt><pre><span class="Keyword">proc</span> <a href="#write%2CFutureStream%5BT%5D%2CT"><span class="Identifier">write</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="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</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>
  218. <dd>
  219. <p>Writes the specified value inside the specified future stream.</p>
  220. <p>This will raise <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> if <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> is finished.</p>
  221. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L85" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  222. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L85" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  223. </dd>
  224. </div>
  225. </div>
  226. </dl>
  227. </div>
  228. </div>
  229. </div>
  230. <div class="twelve-columns footer">
  231. <span class="nim-sprite"></span>
  232. <br>
  233. <small style="color: var(--hint);">Made with Nim. Generated: 2025-03-25 06:49:42 UTC</small>
  234. </div>
  235. </div>
  236. </div>
  237. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  238. </body>
  239. </html>