12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088 |
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <!-- This file is generated by Nim. -->
- <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>std/asyncdispatch</title>
- <!-- Google fonts -->
- <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
- <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
- <!-- Favicon -->
- <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
- <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
- <!-- CSS -->
- <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
- <!-- JS -->
- <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
- </head>
- <body>
- <div class="document" id="documentId">
- <div class="container">
- <h1 class="title">std/asyncdispatch</h1>
- <div class="row">
- <div class="three columns">
- <div class="theme-select-wrapper">
- <label for="theme-select">Theme: </label>
- <select id="theme-select" onchange="setTheme(this.value)">
- <option value="auto">🌗 Match OS</option>
- <option value="dark">🌑 Dark</option>
- <option value="light">🌕 Light</option>
- </select>
- </div>
- <div id="global-links">
- <ul class="simple-boot">
- <li><a href="manual.html">Manual</a></li>
- <li><a href="lib.html">Standard library</a></li>
- <li> <a id="indexLink" href="theindex.html">Index</a></li>
- <li><a href="compiler/theindex.html">Compiler docs</a></li>
- <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
- <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
- </ul>
- </div>
- <div id="searchInputDiv">
- Search: <input type="search" id="searchInput"
- oninput="search()" />
- </div>
-
- <ul class="simple simple-toc" id="toc-list">
- <li><a class="reference" id="asynchronous-procedures_toc" href="#asynchronous-procedures">Asynchronous procedures</a></li>
- <ul class="simple"><li><a class="reference" id="asynchronous-procedures-handling-exceptions_toc" href="#asynchronous-procedures-handling-exceptions">Handling Exceptions</a></li>
- </ul><li><a class="reference" id="discarding-futures_toc" href="#discarding-futures">Discarding futures</a></li>
- <li><a class="reference" id="handling-futures_toc" href="#handling-futures">Handling futures</a></li>
- <li><a class="reference" id="examples_toc" href="#examples">Examples</a></li>
- <li><a class="reference" id="investigating-pending-futures_toc" href="#investigating-pending-futures">Investigating pending futures</a></li>
- <li><a class="reference" id="limitationsslashbugs_toc" href="#limitationsslashbugs">Limitations/Bugs</a></li>
- <li><a class="reference" id="multiple-async-backend-support_toc" href="#multiple-async-backend-support">Multiple async backend support</a></li>
- <li>
- <a class="reference reference-toplevel" href="#6" id="56">Imports</a>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
- <ul class="simple simple-toc-section">
- <li><a class="reference" href="#AsyncEvent" title="AsyncEvent = ptr AsyncEventImpl">AsyncEvent</a></li>
- <li><a class="reference" href="#AsyncFD" title="AsyncFD = distinct int">AsyncFD</a></li>
- <li><a class="reference" href="#Callback" title="Callback = proc (fd: AsyncFD): bool {.closure, gcsafe.}">Callback</a></li>
- <li><a class="reference" href="#CompletionData" title="CompletionData = object
- fd*: AsyncFD
- cb*: owned(proc (fd: AsyncFD; bytesTransferred: DWORD; errcode: OSErrorCode) {.
- closure, gcsafe.})
- cell*: ForeignCell">CompletionData</a></li>
- <li><a class="reference" href="#CustomRef" title="CustomRef = ref CustomObj">CustomRef</a></li>
- <li><a class="reference" href="#PDispatcher" title="PDispatcher = ref object of PDispatcherBase
- handles*: HashSet[AsyncFD]">PDispatcher</a></li>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
- <ul class="simple simple-toc-section">
- <ul class="simple nested-toc-section">==
- <li><a class="reference" href="#%3D%3D%2CAsyncFD%2CAsyncFD" title="`==`(x: AsyncFD; y: AsyncFD): bool">`==`(x: AsyncFD; y: AsyncFD): bool</a></li>
- </ul>
- <ul class="simple nested-toc-section">accept
- <li><a class="reference" href="#accept%2CAsyncFD" title="accept(socket: AsyncFD; flags = {SafeDisconn};
- inheritable = defined(nimInheritHandles)): owned(Future[AsyncFD])">accept(socket: AsyncFD; flags = {SafeDisconn};
- inheritable = defined(nimInheritHandles)): owned(Future[AsyncFD])</a></li>
- </ul>
- <ul class="simple nested-toc-section">acceptAddr
- <li><a class="reference" href="#acceptAddr%2CAsyncFD" title="acceptAddr(socket: AsyncFD; flags = {SafeDisconn};
- inheritable = defined(nimInheritHandles)): owned(
- Future[tuple[address: string, client: AsyncFD]])">acceptAddr(socket: AsyncFD; flags = {SafeDisconn};
- inheritable = defined(nimInheritHandles)): owned(
- Future[tuple[address: string, client: AsyncFD]])</a></li>
- </ul>
- <ul class="simple nested-toc-section">activeDescriptors
- <li><a class="reference" href="#activeDescriptors" title="activeDescriptors(): int">activeDescriptors(): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">addEvent
- <li><a class="reference" href="#addEvent%2CAsyncEvent%2CCallback" title="addEvent(ev: AsyncEvent; cb: Callback)">addEvent(ev: AsyncEvent; cb: Callback)</a></li>
- </ul>
- <ul class="simple nested-toc-section">addProcess
- <li><a class="reference" href="#addProcess%2Cint%2CCallback" title="addProcess(pid: int; cb: Callback)">addProcess(pid: int; cb: Callback)</a></li>
- </ul>
- <ul class="simple nested-toc-section">addRead
- <li><a class="reference" href="#addRead%2CAsyncFD%2CCallback" title="addRead(fd: AsyncFD; cb: Callback)">addRead(fd: AsyncFD; cb: Callback)</a></li>
- </ul>
- <ul class="simple nested-toc-section">addTimer
- <li><a class="reference" href="#addTimer%2Cint%2Cbool%2CCallback" title="addTimer(timeout: int; oneshot: bool; cb: Callback)">addTimer(timeout: int; oneshot: bool; cb: Callback)</a></li>
- </ul>
- <ul class="simple nested-toc-section">addWrite
- <li><a class="reference" href="#addWrite%2CAsyncFD%2CCallback" title="addWrite(fd: AsyncFD; cb: Callback)">addWrite(fd: AsyncFD; cb: Callback)</a></li>
- </ul>
- <ul class="simple nested-toc-section">callSoon
- <li><a class="reference" href="#callSoon%2Cproc%29" title="callSoon(cbproc: proc () {.gcsafe.})">callSoon(cbproc: proc () {.gcsafe.})</a></li>
- </ul>
- <ul class="simple nested-toc-section">close
- <li><a class="reference" href="#close%2CAsyncEvent" title="close(ev: AsyncEvent)">close(ev: AsyncEvent)</a></li>
- </ul>
- <ul class="simple nested-toc-section">closeSocket
- <li><a class="reference" href="#closeSocket%2CAsyncFD" title="closeSocket(socket: AsyncFD)">closeSocket(socket: AsyncFD)</a></li>
- </ul>
- <ul class="simple nested-toc-section">connect
- <li><a class="reference" href="#connect%2CAsyncFD%2Cstring%2CPort" title="connect(socket: AsyncFD; address: string; port: Port; domain = Domain.AF_INET): owned(
- Future[void])">connect(socket: AsyncFD; address: string; port: Port; domain = Domain.AF_INET): owned(
- Future[void])</a></li>
- </ul>
- <ul class="simple nested-toc-section">contains
- <li><a class="reference" href="#contains%2CPDispatcher%2CAsyncFD" title="contains(disp: PDispatcher; fd: AsyncFD): bool">contains(disp: PDispatcher; fd: AsyncFD): bool</a></li>
- </ul>
- <ul class="simple nested-toc-section">createAsyncNativeSocket
- <li><a class="reference" href="#createAsyncNativeSocket%2Ccint%2Ccint%2Ccint" title="createAsyncNativeSocket(domain: cint; sockType: cint; protocol: cint;
- inheritable = defined(nimInheritHandles)): AsyncFD">createAsyncNativeSocket(domain: cint; sockType: cint; protocol: cint;
- inheritable = defined(nimInheritHandles)): AsyncFD</a></li>
- <li><a class="reference" href="#createAsyncNativeSocket%2CDomain%2CSockType%2CProtocol" title="createAsyncNativeSocket(domain: Domain = Domain.AF_INET;
- sockType: SockType = SOCK_STREAM;
- protocol: Protocol = IPPROTO_TCP;
- inheritable = defined(nimInheritHandles)): AsyncFD">createAsyncNativeSocket(domain: Domain = Domain.AF_INET;
- sockType: SockType = SOCK_STREAM;
- protocol: Protocol = IPPROTO_TCP;
- inheritable = defined(nimInheritHandles)): AsyncFD</a></li>
- </ul>
- <ul class="simple nested-toc-section">dial
- <li><a class="reference" href="#dial%2Cstring%2CPort%2CProtocol" title="dial(address: string; port: Port; protocol: Protocol = IPPROTO_TCP): owned(
- Future[AsyncFD])">dial(address: string; port: Port; protocol: Protocol = IPPROTO_TCP): owned(
- Future[AsyncFD])</a></li>
- </ul>
- <ul class="simple nested-toc-section">drain
- <li><a class="reference" href="#drain%2Cint" title="drain(timeout = 500)">drain(timeout = 500)</a></li>
- </ul>
- <ul class="simple nested-toc-section">getGlobalDispatcher
- <li><a class="reference" href="#getGlobalDispatcher" title="getGlobalDispatcher(): PDispatcher">getGlobalDispatcher(): PDispatcher</a></li>
- </ul>
- <ul class="simple nested-toc-section">getIoHandler
- <li><a class="reference" href="#getIoHandler%2CPDispatcher" title="getIoHandler(disp: PDispatcher): Handle">getIoHandler(disp: PDispatcher): Handle</a></li>
- </ul>
- <ul class="simple nested-toc-section">hasPendingOperations
- <li><a class="reference" href="#hasPendingOperations" title="hasPendingOperations(): bool">hasPendingOperations(): bool</a></li>
- </ul>
- <ul class="simple nested-toc-section">maxDescriptors
- <li><a class="reference" href="#maxDescriptors" title="maxDescriptors(): int">maxDescriptors(): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">newAsyncEvent
- <li><a class="reference" href="#newAsyncEvent" title="newAsyncEvent(): AsyncEvent">newAsyncEvent(): AsyncEvent</a></li>
- </ul>
- <ul class="simple nested-toc-section">newCustom
- <li><a class="reference" href="#newCustom" title="newCustom(): CustomRef">newCustom(): CustomRef</a></li>
- </ul>
- <ul class="simple nested-toc-section">newDispatcher
- <li><a class="reference" href="#newDispatcher" title="newDispatcher(): owned PDispatcher">newDispatcher(): owned PDispatcher</a></li>
- </ul>
- <ul class="simple nested-toc-section">poll
- <li><a class="reference" href="#poll%2Cint" title="poll(timeout = 500)">poll(timeout = 500)</a></li>
- </ul>
- <ul class="simple nested-toc-section">readAll
- <li><a class="reference" href="#readAll%2CFutureStream%5Bstring%5D" title="readAll(future: FutureStream[string]): owned(Future[string])">readAll(future: FutureStream[string]): owned(Future[string])</a></li>
- </ul>
- <ul class="simple nested-toc-section">recv
- <li><a class="reference" href="#recv%2CAsyncFD%2Cint" title="recv(socket: AsyncFD; size: int; flags = {SafeDisconn}): owned(Future[string])">recv(socket: AsyncFD; size: int; flags = {SafeDisconn}): owned(Future[string])</a></li>
- </ul>
- <ul class="simple nested-toc-section">recvFromInto
- <li><a class="reference" href="#recvFromInto%2CAsyncFD%2Cpointer%2Cint%2Cptr.SockAddr%2Cptr.SockLen" title="recvFromInto(socket: AsyncFD; data: pointer; size: int; saddr: ptr SockAddr;
- saddrLen: ptr SockLen; flags = {SafeDisconn}): owned(Future[int])">recvFromInto(socket: AsyncFD; data: pointer; size: int; saddr: ptr SockAddr;
- saddrLen: ptr SockLen; flags = {SafeDisconn}): owned(Future[int])</a></li>
- </ul>
- <ul class="simple nested-toc-section">recvInto
- <li><a class="reference" href="#recvInto%2CAsyncFD%2Cpointer%2Cint" title="recvInto(socket: AsyncFD; buf: pointer; size: int; flags = {SafeDisconn}): owned(
- Future[int])">recvInto(socket: AsyncFD; buf: pointer; size: int; flags = {SafeDisconn}): owned(
- Future[int])</a></li>
- </ul>
- <ul class="simple nested-toc-section">register
- <li><a class="reference" href="#register%2CAsyncFD" title="register(fd: AsyncFD)">register(fd: AsyncFD)</a></li>
- </ul>
- <ul class="simple nested-toc-section">runForever
- <li><a class="reference" href="#runForever" title="runForever()">runForever()</a></li>
- </ul>
- <ul class="simple nested-toc-section">send
- <li><a class="reference" href="#send%2CAsyncFD%2Cpointer%2Cint" title="send(socket: AsyncFD; buf: pointer; size: int; flags = {SafeDisconn}): owned(
- Future[void])">send(socket: AsyncFD; buf: pointer; size: int; flags = {SafeDisconn}): owned(
- Future[void])</a></li>
- <li><a class="reference" href="#send%2CAsyncFD%2Cstring" title="send(socket: AsyncFD; data: string; flags = {SafeDisconn}): owned(Future[void])">send(socket: AsyncFD; data: string; flags = {SafeDisconn}): owned(Future[void])</a></li>
- </ul>
- <ul class="simple nested-toc-section">sendTo
- <li><a class="reference" href="#sendTo%2CAsyncFD%2Cpointer%2Cint%2Cptr.SockAddr%2CSockLen" title="sendTo(socket: AsyncFD; data: pointer; size: int; saddr: ptr SockAddr;
- saddrLen: SockLen; flags = {SafeDisconn}): owned(Future[void])">sendTo(socket: AsyncFD; data: pointer; size: int; saddr: ptr SockAddr;
- saddrLen: SockLen; flags = {SafeDisconn}): owned(Future[void])</a></li>
- </ul>
- <ul class="simple nested-toc-section">setGlobalDispatcher
- <li><a class="reference" href="#setGlobalDispatcher%2CsinkPDispatcher" title="setGlobalDispatcher(disp: sink PDispatcher)">setGlobalDispatcher(disp: sink PDispatcher)</a></li>
- </ul>
- <ul class="simple nested-toc-section">setInheritable
- <li><a class="reference" href="#setInheritable%2CAsyncFD%2Cbool" title="setInheritable(fd: AsyncFD; inheritable: bool): bool">setInheritable(fd: AsyncFD; inheritable: bool): bool</a></li>
- </ul>
- <ul class="simple nested-toc-section">sleepAsync
- <li><a class="reference" href="#sleepAsync" title="sleepAsync(ms: int | float): owned(Future[void])">sleepAsync(ms: int | float): owned(Future[void])</a></li>
- </ul>
- <ul class="simple nested-toc-section">trigger
- <li><a class="reference" href="#trigger%2CAsyncEvent" title="trigger(ev: AsyncEvent)">trigger(ev: AsyncEvent)</a></li>
- </ul>
- <ul class="simple nested-toc-section">unregister
- <li><a class="reference" href="#unregister%2CAsyncEvent" title="unregister(ev: AsyncEvent)">unregister(ev: AsyncEvent)</a></li>
- <li><a class="reference" href="#unregister%2CAsyncFD" title="unregister(fd: AsyncFD)">unregister(fd: AsyncFD)</a></li>
- </ul>
- <ul class="simple nested-toc-section">waitFor
- <li><a class="reference" href="#waitFor%2CFuture%5BT%5D" title="waitFor[T](fut: Future[T]): T">waitFor[T](fut: Future[T]): T</a></li>
- </ul>
- <ul class="simple nested-toc-section">withTimeout
- <li><a class="reference" href="#withTimeout%2CFuture%5BT%5D%2Cint" title="withTimeout[T](fut: Future[T]; timeout: int): owned(Future[bool])">withTimeout[T](fut: Future[T]; timeout: int): owned(Future[bool])</a></li>
- </ul>
- </ul>
- </details>
- </li>
- </ul>
- </div>
- <div class="nine columns" id="content">
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
- <div id="tocRoot"></div>
-
- <p class="module-desc"><p>This module implements asynchronous IO. This includes a dispatcher, a <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span></span></tt> type implementation, and an <tt class="docutils literal"><span class="pre"><span class="Identifier">async</span></span></tt> macro which allows asynchronous code to be written in a synchronous style with the <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt> keyword.</p>
- <p>The dispatcher acts as a kind of event loop. You must call <tt class="docutils literal"><span class="pre"><span class="Identifier">poll</span></span></tt> on it (or a function which does so for you such as <tt class="docutils literal"><span class="pre"><span class="Identifier">waitFor</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">runForever</span></span></tt>) in order to poll for any outstanding events. The underlying implementation is based on epoll on Linux, IO Completion Ports on Windows and select on other operating systems.</p>
- <p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">poll</span></span></tt> function will not, on its own, return any events. Instead an appropriate <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span></span></tt> object will be completed. A <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span></span></tt> is a type which holds a value which is not yet available, but which <em>may</em> be available in the future. You can check whether a future is finished by using the <tt class="docutils literal"><span class="pre"><span class="Identifier">finished</span></span></tt> function. When a future is finished it means that either the value that it holds is now available or it holds an error instead. The latter situation occurs when the operation to complete a future fails with an exception. You can distinguish between the two situations with the <tt class="docutils literal"><span class="pre"><span class="Identifier">failed</span></span></tt> function.</p>
- <p>Future objects can also store a callback procedure which will be called automatically once the future completes.</p>
- <p>Futures therefore can be thought of as an implementation of the proactor pattern. In this pattern you make a request for an action, and once that action is fulfilled a future is completed with the result of that action. Requests can be made by calling the appropriate functions. For example: calling the <tt class="docutils literal"><span class="pre"><span class="Identifier">recv</span></span></tt> function will create a request for some data to be read from a socket. The future which the <tt class="docutils literal"><span class="pre"><span class="Identifier">recv</span></span></tt> function returns will then complete once the requested amount of data is read <strong>or</strong> an exception occurs.</p>
- <p>Code to read some data from a socket may look something like this:</p>
- <p><pre class="listing"><span class="Keyword">var</span> <span class="Identifier">future</span> <span class="Operator">=</span> <span class="Identifier">socket</span><span class="Operator">.</span><span class="Identifier">recv</span><span class="Punctuation">(</span><span class="DecNumber">100</span><span class="Punctuation">)</span>
- <span class="Identifier">future</span><span class="Operator">.</span><span class="Identifier">addCallback</span><span class="Punctuation">(</span>
- <span class="Keyword">proc</span> <span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">=</span>
- <span class="Identifier">echo</span><span class="Punctuation">(</span><span class="Identifier">future</span><span class="Operator">.</span><span class="Identifier">read</span><span class="Punctuation">)</span>
- <span class="Punctuation">)</span></pre></p>
- <p>All asynchronous functions returning a <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span></span></tt> will not block. They will not however return immediately. An asynchronous function will have code which will be executed before an asynchronous request is made, in most cases this code sets up the request.</p>
- <p>In the above example, the <tt class="docutils literal"><span class="pre"><span class="Identifier">recv</span></span></tt> function will return a brand new <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span></span></tt> instance once the request for data to be read from the socket is made. This <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span></span></tt> instance will complete once the requested amount of data is read, in this case it is 100 bytes. The second line sets a callback on this future which will be called once the future completes. All the callback does is write the data stored in the future to <tt class="docutils literal"><span class="pre"><span class="Identifier">stdout</span></span></tt>. The <tt class="docutils literal"><span class="pre"><span class="Identifier">read</span></span></tt> function is used for this and it checks whether the future completes with an error for you (if it did, it will simply raise the error), if there is no error, however, it returns the value of the future.</p>
- <h1><a class="toc-backref" id="asynchronous-procedures" href="#asynchronous-procedures">Asynchronous procedures</a></h1><p>Asynchronous procedures remove the pain of working with callbacks. They do this by allowing you to write asynchronous code the same way as you would write synchronous code.</p>
- <p>An asynchronous procedure is marked using the <tt class="docutils literal"><span class="pre"><span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span></span></tt> pragma. When marking a procedure with the <tt class="docutils literal"><span class="pre"><span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span></span></tt> pragma it must have a <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt> return type or no return type at all. If you do not specify a return type then <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> is assumed.</p>
- <p>Inside asynchronous procedures <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt> can be used to call any procedures which return a <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span></span></tt>; this includes asynchronous procedures. When a procedure is "awaited", the asynchronous procedure it is awaited in will suspend its execution until the awaited procedure's Future completes. At which point the asynchronous procedure will resume its execution. During the period when an asynchronous procedure is suspended other asynchronous procedures will be run by the dispatcher.</p>
- <p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt> call may be used in many contexts. It can be used on the right hand side of a variable declaration: <tt class="docutils literal"><span class="pre"><span class="Keyword">var</span> <span class="Identifier">data</span> <span class="Operator">=</span> <span class="Identifier">await</span> <span class="Identifier">socket</span><span class="Operator">.</span><span class="Identifier">recv</span><span class="Punctuation">(</span><span class="DecNumber">100</span><span class="Punctuation">)</span></span></tt>, in which case the variable will be set to the value of the future automatically. It can be used to await a <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span></span></tt> object, and it can be used to await a procedure returning a <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>: <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span> <span class="Identifier">socket</span><span class="Operator">.</span><span class="Identifier">send</span><span class="Punctuation">(</span><span class="StringLit">"foobar"</span><span class="Punctuation">)</span></span></tt>.</p>
- <p>If an awaited future completes with an error, then <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt> will re-raise this error. To avoid this, you can use the <tt class="docutils literal"><span class="pre"><span class="Keyword">yield</span></span></tt> keyword instead of <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt>. The following section shows different ways that you can handle exceptions in async procs.</p>
- <div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Caution:</b></span>
- Procedures marked {.async.} do not support mutable parameters such as <tt class="docutils literal"><span class="pre"><span class="Keyword">var</span> <span class="Identifier">int</span></span></tt>. References such as <tt class="docutils literal"><span class="pre"><span class="Keyword">ref</span> <span class="Identifier">int</span></span></tt> should be used instead.</div>
- <h2><a class="toc-backref" id="asynchronous-procedures-handling-exceptions" href="#asynchronous-procedures-handling-exceptions">Handling Exceptions</a></h2><p>You can handle exceptions in the same way as in ordinary Nim code; by using the try statement:</p>
- <p><pre class="listing"><span class="Keyword">try</span><span class="Punctuation">:</span>
- <span class="Keyword">let</span> <span class="Identifier">data</span> <span class="Operator">=</span> <span class="Identifier">await</span> <span class="Identifier">sock</span><span class="Operator">.</span><span class="Identifier">recv</span><span class="Punctuation">(</span><span class="DecNumber">100</span><span class="Punctuation">)</span>
- <span class="Identifier">echo</span><span class="Punctuation">(</span><span class="StringLit">"Received "</span><span class="Punctuation">,</span> <span class="Identifier">data</span><span class="Punctuation">)</span>
- <span class="Keyword">except</span><span class="Punctuation">:</span>
- <span class="Comment"># Handle exception</span></pre></p>
- <p>An alternative approach to handling exceptions is to use <tt class="docutils literal"><span class="pre"><span class="Keyword">yield</span></span></tt> on a future then check the future's <tt class="docutils literal"><span class="pre"><span class="Identifier">failed</span></span></tt> property. For example:</p>
- <p><pre class="listing"><span class="Keyword">var</span> <span class="Identifier">future</span> <span class="Operator">=</span> <span class="Identifier">sock</span><span class="Operator">.</span><span class="Identifier">recv</span><span class="Punctuation">(</span><span class="DecNumber">100</span><span class="Punctuation">)</span>
- <span class="Keyword">yield</span> <span class="Identifier">future</span>
- <span class="Keyword">if</span> <span class="Identifier">future</span><span class="Operator">.</span><span class="Identifier">failed</span><span class="Punctuation">:</span>
- <span class="Comment"># Handle exception</span></pre></p>
- <h1><a class="toc-backref" id="discarding-futures" href="#discarding-futures">Discarding futures</a></h1><p>Futures should <strong>never</strong> be discarded directly because they may contain errors. If you do not care for the result of a Future then you should use the <tt class="docutils literal"><span class="pre"><span class="Identifier">asyncCheck</span></span></tt> procedure instead of the <tt class="docutils literal"><span class="pre"><span class="Keyword">discard</span></span></tt> keyword. Note that this does not wait for completion, and you should use <tt class="docutils literal"><span class="pre"><span class="Identifier">waitFor</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt> for that purpose.</p>
- <div class="admonition admonition-info"><span class="admonition-info-text"><b>Note:</b></span>
- <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt> also checks if the future fails, so you can safely discard its result.</div>
- <h1><a class="toc-backref" id="handling-futures" href="#handling-futures">Handling futures</a></h1><p>There are many different operations that apply to a future. The three primary high-level operations are <tt class="docutils literal"><span class="pre"><span class="Identifier">asyncCheck</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">waitFor</span></span></tt>, and <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt>.</p>
- <ul class="simple"><li><tt class="docutils literal"><span class="pre"><span class="Identifier">asyncCheck</span></span></tt>: Raises an exception if the future fails. It neither waits for the future to finish nor returns the result of the future.</li>
- <li><tt class="docutils literal"><span class="pre"><span class="Identifier">waitFor</span></span></tt>: Polls the event loop and blocks the current thread until the future finishes. This is often used to call an async procedure from a synchronous context and should never be used in an <tt class="docutils literal"><span class="pre"><span class="Identifier">async</span></span></tt> proc.</li>
- <li><tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt>: Pauses execution in the current async procedure until the future finishes. While the current procedure is paused, other async procedures will continue running. Should be used instead of <tt class="docutils literal"><span class="pre"><span class="Identifier">waitFor</span></span></tt> in an async procedure.</li>
- </ul>
- <p>Here is a handy quick reference chart showing their high-level differences:</p>
- <table border="1" class="docutils"><tr><th>Procedure</th><th>Context</th><th>Blocking</th></tr>
- <tr><td><tt class="docutils literal"><span class="pre"><span class="Identifier">asyncCheck</span></span></tt></td><td>non-async and async</td><td>non-blocking</td></tr>
- <tr><td><tt class="docutils literal"><span class="pre"><span class="Identifier">waitFor</span></span></tt></td><td>non-async</td><td>blocks current thread</td></tr>
- <tr><td><tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt></td><td>async</td><td>suspends current proc</td></tr>
- </table>
- <h1><a class="toc-backref" id="examples" href="#examples">Examples</a></h1><p>For examples take a look at the documentation for the modules implementing asynchronous IO. A good place to start is the <a class="reference external" href="asyncnet.html">asyncnet module</a>.</p>
- <h1><a class="toc-backref" id="investigating-pending-futures" href="#investigating-pending-futures">Investigating pending futures</a></h1><p>It's possible to get into a situation where an async proc, or more accurately a <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt> gets stuck and never completes. This can happen for various reasons and can cause serious memory leaks. When this occurs it's hard to identify the procedure that is stuck.</p>
- <p>Thankfully there is a mechanism which tracks the count of each pending future. All you need to do to enable it is compile with <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">futureLogging</span></span></tt> and use the <tt class="docutils literal"><span class="pre"><span class="Identifier">getFuturesInProgress</span></span></tt> procedure to get the list of pending futures together with the stack traces to the moment of their creation.</p>
- <p>You may also find it useful to use this <a class="reference external" href="https://github.com/dom96/prometheus">prometheus package</a> which will log the pending futures into prometheus, allowing you to analyse them via a nice graph.</p>
- <h1><a class="toc-backref" id="limitationsslashbugs" href="#limitationsslashbugs">Limitations/Bugs</a></h1><ul class="simple"><li>The effect system (<tt class="docutils literal"><span class="pre"><span class="Identifier">raises</span><span class="Punctuation">:</span> <span class="Punctuation">[</span><span class="Punctuation">]</span></span></tt>) does not work with async procedures.</li>
- <li>Mutable parameters are not supported by async procedures.</li>
- </ul>
- <h1><a class="toc-backref" id="multiple-async-backend-support" href="#multiple-async-backend-support">Multiple async backend support</a></h1><p>Thanks to its powerful macro support, Nim allows <tt class="docutils literal"><span class="pre">async</span></tt>/<tt class="docutils literal"><span class="pre">await</span></tt> to be implemented in libraries with only minimal support from the language - as such, multiple <tt class="docutils literal"><span class="pre">async</span></tt> libraries exist, including <tt class="docutils literal"><span class="pre">asyncdispatch</span></tt> and <tt class="docutils literal"><span class="pre">chronos</span></tt>, and more may come to be developed in the future.</p>
- <p>Libraries built on top of async/await may wish to support multiple async backends - the best way to do so is to create separate modules for each backend that may be imported side-by-side.</p>
- <p>An alternative way is to select backend using a global compile flag - this method makes it difficult to compose applications that use both backends as may happen with transitive dependencies, but may be appropriate in some cases - libraries choosing this path should call the flag <tt class="docutils literal"><span class="pre"><span class="Identifier">asyncBackend</span></span></tt>, allowing applications to choose the backend with <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">asyncBackend</span><span class="Operator">=<</span><span class="Identifier">backend_name</span><span class="Operator">></span></span></tt>.</p>
- <p>Known <tt class="docutils literal"><span class="pre"><span class="Identifier">async</span></span></tt> backends include:</p>
- <ul class="simple"><li><tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">asyncBackend</span><span class="Operator">=</span><span class="Identifier">none</span></span></tt>: disable <tt class="docutils literal"><span class="pre"><span class="Identifier">async</span></span></tt> support completely</li>
- <li><tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">asyncBackend</span><span class="Operator">=</span><span class="Identifier">asyncdispatch</span></span></tt>: <a class="reference external" href="https://nim-lang.org/docs/asyncdispatch.html">https://nim-lang.org/docs/asyncdispatch.html</a></li>
- <li><tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">asyncBackend</span><span class="Operator">=</span><span class="Identifier">chronos</span></span></tt>: <a class="reference external" href="https://github.com/status-im/nim-chronos/">https://github.com/status-im/nim-chronos/</a></li>
- </ul>
- <p><tt class="docutils literal"><span class="pre">none</span></tt> can be used when a library supports both a synchronous and asynchronous API, to disable the latter.</p>
- </p>
- <div class="section" id="6">
- <h1><a class="toc-backref" href="#6">Imports</a></h1>
- <dl class="item">
- <a class="reference external" href="os.html">os</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="asyncstreams.html">asyncstreams</a>, <a class="reference external" href="math.html">math</a>, <a class="reference external" href="monotimes.html">monotimes</a>, <a class="reference external" href="asyncfutures.html">asyncfutures</a>, <a class="reference external" href="nativesockets.html">nativesockets</a>, <a class="reference external" href="net.html">net</a>, <a class="reference external" href="deques.html">deques</a>, <a class="reference external" href="assertions.html">assertions</a>, <a class="reference external" href="syncio.html">syncio</a>, <a class="reference external" href="winlean.html">winlean</a>, <a class="reference external" href="sets.html">sets</a>, <a class="reference external" href="hashes.html">hashes</a>, <a class="reference external" href="asyncmacro.html">asyncmacro</a>, <a class="reference external" href="posix.html">posix</a>
- </dl>
- </div>
- <div class="section" id="7">
- <h1><a class="toc-backref" href="#7">Types</a></h1>
- <dl class="item">
- <div id="AsyncEvent">
- <dt><pre><a href="asyncdispatch.html#AsyncEvent"><span class="Identifier">AsyncEvent</span></a> <span class="Other">=</span> <span class="Keyword">ptr</span> <span class="Identifier">AsyncEventImpl</span></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L339" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L339" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="AsyncFD">
- <dt><pre><a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a> <span class="Other">=</span> <span class="Keyword">distinct</span> <a href="system.html#int"><span class="Identifier">int</span></a></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L326" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L326" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="Callback">
- <dt><pre><a href="asyncdispatch.html#Callback"><span class="Identifier">Callback</span></a> <span class="Other">=</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">fd</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<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>.}</pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L341" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L341" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="CompletionData">
- <dt><pre><a href="asyncdispatch.html#CompletionData"><span class="Identifier">CompletionData</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
- <span class="Identifier">fd</span><span class="Operator">*</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a>
- <span class="Identifier">cb</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">fd</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">bytesTransferred</span><span class="Other">:</span> <a href="winlean.html#DWORD"><span class="Identifier">DWORD</span></a><span class="Other">;</span> <span class="Identifier">errcode</span><span class="Other">:</span> <a href="oserrors.html#OSErrorCode"><span class="Identifier">OSErrorCode</span></a><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>
- <span class="Identifier">cell</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#ForeignCell"><span class="Identifier">ForeignCell</span></a></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L309" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L309" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="CustomRef">
- <dt><pre><a href="asyncdispatch.html#CustomRef"><span class="Identifier">CustomRef</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Identifier">CustomObj</span></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L324" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L324" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="PDispatcher">
- <dt><pre><a href="asyncdispatch.html#PDispatcher"><span class="Identifier">PDispatcher</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">PDispatcherBase</span>
- <span class="Identifier">handles</span><span class="Operator">*</span><span class="Other">:</span> <a href="sets.html#HashSet"><span class="Identifier">HashSet</span></a><span class="Other">[</span><a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">]</span></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L317" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L317" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </dl>
- </div>
- <div class="section" id="12">
- <h1><a class="toc-backref" href="#12">Procs</a></h1>
- <dl class="item">
- <div id="==-procs-all">
- <div id="==,AsyncFD,AsyncFD">
- <dt><pre><span class="Keyword">proc</span> <a href="#%3D%3D%2CAsyncFD%2CAsyncFD"><span class="Identifier">`==`</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">y</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">borrow</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> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L344" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L344" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="accept-procs-all">
- <div id="accept,AsyncFD">
- <dt><pre><span class="Keyword">proc</span> <a href="#accept%2CAsyncFD"><span class="Identifier">accept</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">;</span>
- <span class="Identifier">inheritable</span> <span class="Other">=</span> <span class="Identifier">defined</span><span class="Other">(</span><span class="Identifier">nimInheritHandles</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><a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><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="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</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>
- <dd>
-
- <p>Accepts a new connection. Returns a future containing the client socket corresponding to that connection.</p>
- <p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">inheritable</span></span></tt> is false (the default), the resulting client socket will not be inheritable by child processes.</p>
- <p>The future will complete when the connection is successfully accepted.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1954" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1954" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="acceptAddr-procs-all">
- <div id="acceptAddr,AsyncFD">
- <dt><pre><span class="Keyword">proc</span> <a href="#acceptAddr%2CAsyncFD"><span class="Identifier">acceptAddr</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">;</span>
- <span class="Identifier">inheritable</span> <span class="Other">=</span> <span class="Identifier">defined</span><span class="Other">(</span><span class="Identifier">nimInheritHandles</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="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">address</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <span class="Identifier">client</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><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 class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</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>
- <dd>
-
- <p>Accepts a new connection. Returns a future containing the client socket corresponding to that connection and the remote address of the client. The future will complete when the connection is successfully accepted.</p>
- <p>The resulting client socket is automatically registered to the dispatcher.</p>
- <p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">inheritable</span></span></tt> is false (the default), the resulting client socket will not be inheritable by child processes.</p>
- <p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">accept</span></span></tt> call may result in an error if the connecting socket disconnects during the duration of the <tt class="docutils literal"><span class="pre"><span class="Identifier">accept</span></span></tt>. If the <tt class="docutils literal"><span class="pre"><span class="Identifier">SafeDisconn</span></span></tt> flag is specified then this error will not be raised and instead accept will be called again.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L771" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L771" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="activeDescriptors-procs-all">
- <div id="activeDescriptors">
- <dt><pre><span class="Keyword">proc</span> <a href="#activeDescriptors"><span class="Identifier">activeDescriptors</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> {.<span class="Identifier">inline</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> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Returns the current number of active file descriptors for the current event loop. This is a cheap operation that does not involve a system call.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L2027" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L2027" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="addEvent-procs-all">
- <div id="addEvent,AsyncEvent,Callback">
- <dt><pre><span class="Keyword">proc</span> <a href="#addEvent%2CAsyncEvent%2CCallback"><span class="Identifier">addEvent</span></a><span class="Other">(</span><span class="Identifier">ev</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncEvent"><span class="Identifier">AsyncEvent</span></a><span class="Other">;</span> <span class="Identifier">cb</span><span class="Other">:</span> <a href="asyncdispatch.html#Callback"><span class="Identifier">Callback</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="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Registers callback <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> to be called when <tt class="docutils literal"><span class="pre"><span class="Identifier">ev</span></span></tt> will be signaled
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1136" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1136" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="addProcess-procs-all">
- <div id="addProcess,int,Callback">
- <dt><pre><span class="Keyword">proc</span> <a href="#addProcess%2Cint%2CCallback"><span class="Identifier">addProcess</span></a><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">cb</span><span class="Other">:</span> <a href="asyncdispatch.html#Callback"><span class="Identifier">Callback</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="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Registers callback <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> to be called when process with process ID <tt class="docutils literal"><span class="pre"><span class="Identifier">pid</span></span></tt> exited.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1079" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1079" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="addRead-procs-all">
- <div id="addRead,AsyncFD,Callback">
- <dt><pre><span class="Keyword">proc</span> <a href="#addRead%2CAsyncFD%2CCallback"><span class="Identifier">addRead</span></a><span class="Other">(</span><span class="Identifier">fd</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">cb</span><span class="Other">:</span> <a href="asyncdispatch.html#Callback"><span class="Identifier">Callback</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="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <p>Start watching the file descriptor for read availability and then call the callback <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt>.</p>
- <p>This is not <tt class="docutils literal"><span class="pre"><span class="Identifier">pure</span></span></tt> mechanism for Windows Completion Ports (IOCP), so if you can avoid it, please do it. Use <tt class="docutils literal"><span class="pre"><span class="Identifier">addRead</span></span></tt> only if really need it (main usecase is adaptation of unix-like libraries to be asynchronous on Windows).</p>
- <p>If you use this function, you don't need to use asyncdispatch.recv() or asyncdispatch.accept(), because they are using IOCP, please use nativesockets.recv() and nativesockets.accept() instead.</p>
- <p>Be sure your callback <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> returns <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt>, if you want to remove watch of <tt class="docutils literal"><span class="pre"><span class="Identifier">read</span></span></tt> notifications, and <tt class="docutils literal"><span class="pre"><span class="Identifier">false</span></span></tt>, if you want to continue receiving notifications.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L974" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L974" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="addTimer-procs-all">
- <div id="addTimer,int,bool,Callback">
- <dt><pre><span class="Keyword">proc</span> <a href="#addTimer%2Cint%2Cbool%2CCallback"><span class="Identifier">addTimer</span></a><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">cb</span><span class="Other">:</span> <a href="asyncdispatch.html#Callback"><span class="Identifier">Callback</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="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <p>Registers callback <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> to be called when timer expired.</p>
- <p>Parameters:</p>
- <ul class="simple"><li><tt class="docutils literal"><span class="pre"><span class="Identifier">timeout</span></span></tt> - timeout value in milliseconds.</li>
- <li><tt class="docutils literal"><span class="pre"><span class="Identifier">oneshot</span></span></tt><ul class="simple"><li><tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt> - generate only one timeout event</li>
- <li><tt class="docutils literal"><span class="pre"><span class="Identifier">false</span></span></tt> - generate timeout events periodically</li>
- </ul>
- </li>
- </ul>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1045" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1045" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="addWrite-procs-all">
- <div id="addWrite,AsyncFD,Callback">
- <dt><pre><span class="Keyword">proc</span> <a href="#addWrite%2CAsyncFD%2CCallback"><span class="Identifier">addWrite</span></a><span class="Other">(</span><span class="Identifier">fd</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">cb</span><span class="Other">:</span> <a href="asyncdispatch.html#Callback"><span class="Identifier">Callback</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="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <p>Start watching the file descriptor for write availability and then call the callback <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt>.</p>
- <p>This is not <tt class="docutils literal"><span class="pre"><span class="Identifier">pure</span></span></tt> mechanism for Windows Completion Ports (IOCP), so if you can avoid it, please do it. Use <tt class="docutils literal"><span class="pre"><span class="Identifier">addWrite</span></span></tt> only if really need it (main usecase is adaptation of unix-like libraries to be asynchronous on Windows).</p>
- <p>If you use this function, you don't need to use asyncdispatch.send() or asyncdispatch.connect(), because they are using IOCP, please use nativesockets.send() and nativesockets.connect() instead.</p>
- <p>Be sure your callback <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> returns <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt>, if you want to remove watch of <tt class="docutils literal"><span class="pre"><span class="Identifier">write</span></span></tt> notifications, and <tt class="docutils literal"><span class="pre"><span class="Identifier">false</span></span></tt>, if you want to continue receiving notifications.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L992" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L992" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="callSoon-procs-all">
- <div id="callSoon,proc)">
- <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">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Schedule <tt class="docutils literal"><span class="pre"><span class="Identifier">cbproc</span></span></tt> to be called as soon as possible. The callback is called when control returns to the event loop.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L286" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L286" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="close-procs-all">
- <div id="close,AsyncEvent">
- <dt><pre><span class="Keyword">proc</span> <a href="#close%2CAsyncEvent"><span class="Identifier">close</span></a><span class="Other">(</span><span class="Identifier">ev</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncEvent"><span class="Identifier">AsyncEvent</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="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Closes event <tt class="docutils literal"><span class="pre"><span class="Identifier">ev</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1129" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1129" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="closeSocket-procs-all">
- <div id="closeSocket,AsyncFD">
- <dt><pre><span class="Keyword">proc</span> <a href="#closeSocket%2CAsyncFD"><span class="Identifier">closeSocket</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Closes a socket and ensures that it is unregistered.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L870" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L870" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="connect-procs-all">
- <div id="connect,AsyncFD,string,Port">
- <dt><pre><span class="Keyword">proc</span> <a href="#connect%2CAsyncFD%2Cstring%2CPort"><span class="Identifier">connect</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">address</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">port</span><span class="Other">:</span> <a href="nativesockets.html#Port"><span class="Identifier">Port</span></a><span class="Other">;</span>
- <span class="Identifier">domain</span> <span class="Other">=</span> <a href="nativesockets.html#Domain"><span class="Identifier">Domain</span></a><span class="Other">.</span><span class="Identifier">AF_INET</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><a href="system.html#void"><span class="Identifier">void</span></a><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="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">ValueError</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>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1905" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1905" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="contains-procs-all">
- <div id="contains,PDispatcher,AsyncFD">
- <dt><pre><span class="Keyword">proc</span> <a href="#contains%2CPDispatcher%2CAsyncFD"><span class="Identifier">contains</span></a><span class="Other">(</span><span class="Identifier">disp</span><span class="Other">:</span> <a href="asyncdispatch.html#PDispatcher"><span class="Identifier">PDispatcher</span></a><span class="Other">;</span> <span class="Identifier">fd</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</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>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L879" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L879" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="createAsyncNativeSocket-procs-all">
- <div id="createAsyncNativeSocket,cint,cint,cint">
- <dt><pre><span class="Keyword">proc</span> <a href="#createAsyncNativeSocket%2Ccint%2Ccint%2Ccint"><span class="Identifier">createAsyncNativeSocket</span></a><span class="Other">(</span><span class="Identifier">domain</span><span class="Other">:</span> <a href="ctypes.html#cint"><span class="Identifier">cint</span></a><span class="Other">;</span> <span class="Identifier">sockType</span><span class="Other">:</span> <a href="ctypes.html#cint"><span class="Identifier">cint</span></a><span class="Other">;</span> <span class="Identifier">protocol</span><span class="Other">:</span> <a href="ctypes.html#cint"><span class="Identifier">cint</span></a><span class="Other">;</span>
- <span class="Identifier">inheritable</span> <span class="Other">=</span> <span class="Identifier">defined</span><span class="Other">(</span><span class="Identifier">nimInheritHandles</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</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="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1725" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1725" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="createAsyncNativeSocket,Domain,SockType,Protocol">
- <dt><pre><span class="Keyword">proc</span> <a href="#createAsyncNativeSocket%2CDomain%2CSockType%2CProtocol"><span class="Identifier">createAsyncNativeSocket</span></a><span class="Other">(</span><span class="Identifier">domain</span><span class="Other">:</span> <a href="nativesockets.html#Domain"><span class="Identifier">Domain</span></a> <span class="Other">=</span> <a href="nativesockets.html#Domain"><span class="Identifier">Domain</span></a><span class="Other">.</span><span class="Identifier">AF_INET</span><span class="Other">;</span>
- <span class="Identifier">sockType</span><span class="Other">:</span> <a href="nativesockets.html#SockType"><span class="Identifier">SockType</span></a> <span class="Other">=</span> <span class="Identifier">SOCK_STREAM</span><span class="Other">;</span>
- <span class="Identifier">protocol</span><span class="Other">:</span> <a href="nativesockets.html#Protocol"><span class="Identifier">Protocol</span></a> <span class="Other">=</span> <span class="Identifier">IPPROTO_TCP</span><span class="Other">;</span>
- <span class="Identifier">inheritable</span> <span class="Other">=</span> <span class="Identifier">defined</span><span class="Other">(</span><span class="Identifier">nimInheritHandles</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</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="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1730" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1730" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="dial-procs-all">
- <div id="dial,string,Port,Protocol">
- <dt><pre><span class="Keyword">proc</span> <a href="#dial%2Cstring%2CPort%2CProtocol"><span class="Identifier">dial</span></a><span class="Other">(</span><span class="Identifier">address</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">port</span><span class="Other">:</span> <a href="nativesockets.html#Port"><span class="Identifier">Port</span></a><span class="Other">;</span> <span class="Identifier">protocol</span><span class="Other">:</span> <a href="nativesockets.html#Protocol"><span class="Identifier">Protocol</span></a> <span class="Other">=</span> <span class="Identifier">IPPROTO_TCP</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><a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><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="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">ValueError</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>
- <dd>
-
- Establishes connection to the specified <tt class="docutils literal"><span class="pre"><span class="Identifier">address</span></span></tt>:<tt class="docutils literal"><span class="pre"><span class="Identifier">port</span></span></tt> pair via the specified protocol. The procedure iterates through possible resolutions of the <tt class="docutils literal"><span class="pre"><span class="Identifier">address</span></span></tt> until it succeeds, meaning that it seamlessly works with both IPv4 and IPv6. Returns the async file descriptor, registered in the dispatcher of the current thread, ready to send or receive data.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1890" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1890" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="drain-procs-all">
- <div id="drain,int">
- <dt><pre><span class="Keyword">proc</span> <a href="#drain%2Cint"><span class="Identifier">drain</span></a><span class="Other">(</span><span class="Identifier">timeout</span> <span class="Other">=</span> <span class="DecNumber">500</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">ValueError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">OSError</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">TimeEffect</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>
- <dd>
-
- Waits for completion of <strong>all</strong> events and processes them. Raises <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> if there are no pending operations. In contrast to <tt class="docutils literal"><span class="pre"><span class="Identifier">poll</span></span></tt> this processes as many events as are available until the timeout has elapsed.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1696" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1696" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="getGlobalDispatcher-procs-all">
- <div id="getGlobalDispatcher">
- <dt><pre><span class="Keyword">proc</span> <a href="#getGlobalDispatcher"><span class="Identifier">getGlobalDispatcher</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncdispatch.html#PDispatcher"><span class="Identifier">PDispatcher</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L362" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L362" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="getIoHandler-procs-all">
- <div id="getIoHandler,PDispatcher">
- <dt><pre><span class="Keyword">proc</span> <a href="#getIoHandler%2CPDispatcher"><span class="Identifier">getIoHandler</span></a><span class="Other">(</span><span class="Identifier">disp</span><span class="Other">:</span> <a href="asyncdispatch.html#PDispatcher"><span class="Identifier">PDispatcher</span></a><span class="Other">)</span><span class="Other">:</span> <a href="winlean.html#Handle"><span class="Identifier">Handle</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Returns the underlying IO Completion Port handle (Windows) or selector (Unix) for the specified dispatcher.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L367" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L367" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="hasPendingOperations-procs-all">
- <div id="hasPendingOperations">
- <dt><pre><span class="Keyword">proc</span> <a href="#hasPendingOperations"><span class="Identifier">hasPendingOperations</span></a><span class="Other">(</span><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>
- <dd>
-
- Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt> if the global dispatcher has pending operations.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L390" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L390" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="maxDescriptors-procs-all">
- <div id="maxDescriptors">
- <dt><pre><span class="Keyword">proc</span> <a href="#maxDescriptors"><span class="Identifier">maxDescriptors</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> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <a href="exceptions.html#OSError"><span class="Identifier">OSError</span></a><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Returns the maximum number of active file descriptors for the current process. This involves a system call. For now <tt class="docutils literal"><span class="pre"><span class="Identifier">maxDescriptors</span></span></tt> is supported on the following OSes: Windows, Linux, OSX, BSD, Solaris.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L2040" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L2040" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newAsyncEvent-procs-all">
- <div id="newAsyncEvent">
- <dt><pre><span class="Keyword">proc</span> <a href="#newAsyncEvent"><span class="Identifier">newAsyncEvent</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncEvent"><span class="Identifier">AsyncEvent</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="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <p>Creates a new thread-safe <tt class="docutils literal"><span class="pre"><span class="Identifier">AsyncEvent</span></span></tt> object.</p>
- <p>New <tt class="docutils literal"><span class="pre"><span class="Identifier">AsyncEvent</span></span></tt> object is not automatically registered with dispatcher like <tt class="docutils literal"><span class="pre"><span class="Identifier">AsyncSocket</span></span></tt>.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1098" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1098" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newCustom-procs-all">
- <div id="newCustom">
- <dt><pre><span class="Keyword">proc</span> <a href="#newCustom"><span class="Identifier">newCustom</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncdispatch.html#CustomRef"><span class="Identifier">CustomRef</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L487" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L487" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newDispatcher-procs-all">
- <div id="newDispatcher">
- <dt><pre><span class="Keyword">proc</span> <a href="#newDispatcher"><span class="Identifier">newDispatcher</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span> <span class="Identifier">PDispatcher</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Creates a new Dispatcher instance.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L346" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L346" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="poll-procs-all">
- <div id="poll,int">
- <dt><pre><span class="Keyword">proc</span> <a href="#poll%2Cint"><span class="Identifier">poll</span></a><span class="Other">(</span><span class="Identifier">timeout</span> <span class="Other">=</span> <span class="DecNumber">500</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">ValueError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">OSError</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">TimeEffect</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>
- <dd>
-
- Waits for completion events and processes them. Raises <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> if there are no pending operations. This runs the underlying OS <span id="epoll_1">epoll</span> or <span id="kqueue_1">kqueue</span> primitive only once.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1708" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1708" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="readAll-procs-all">
- <div id="readAll,FutureStream[string]">
- <dt><pre><span class="Keyword">proc</span> <a href="#readAll%2CFutureStream%5Bstring%5D"><span class="Identifier">readAll</span></a><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><a href="system.html#string"><span class="Identifier">string</span></a><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><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">)</span> {.
- <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</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="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>
- <dd>
-
- Returns a future that will complete when all the string data from the specified future stream is retrieved.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L2001" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L2001" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="recv-procs-all">
- <div id="recv,AsyncFD,int">
- <dt><pre><span class="Keyword">proc</span> <a href="#recv%2CAsyncFD%2Cint"><span class="Identifier">recv</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</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><a href="system.html#string"><span class="Identifier">string</span></a><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="Identifier">ValueError</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>
- <dd>
-
- Reads <strong>up to</strong> <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt> bytes from <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt>. Returned future will complete once all the data requested is read, a part of the data has been read, or the socket has disconnected in which case the future will complete with a value of <tt class="docutils literal"><span class="pre"><span class="StringLit">""</span></span></tt>.<div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Warning:</b></span>
- The <tt class="docutils literal"><span class="pre"><span class="Identifier">Peek</span></span></tt> socket flag is not supported on Windows.</div>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L494" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L494" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="recvFromInto-procs-all">
- <div id="recvFromInto,AsyncFD,pointer,int,ptr.SockAddr,ptr.SockLen">
- <dt><pre><span class="Keyword">proc</span> <a href="#recvFromInto%2CAsyncFD%2Cpointer%2Cint%2Cptr.SockAddr%2Cptr.SockLen"><span class="Identifier">recvFromInto</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <a href="system.html#pointer"><span class="Identifier">pointer</span></a><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span>
- <span class="Identifier">saddr</span><span class="Other">:</span> <span class="Keyword">ptr</span> <a href="winlean.html#SockAddr"><span class="Identifier">SockAddr</span></a><span class="Other">;</span> <span class="Identifier">saddrLen</span><span class="Other">:</span> <span class="Keyword">ptr</span> <a href="winlean.html#SockLen"><span class="Identifier">SockLen</span></a><span class="Other">;</span>
- <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</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><a href="system.html#int"><span class="Identifier">int</span></a><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="Identifier">ValueError</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>
- <dd>
-
- Receives a datagram data from <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt> into <tt class="docutils literal"><span class="pre"><span class="Identifier">buf</span></span></tt>, which must be at least of size <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt>, address of datagram's sender will be stored into <tt class="docutils literal"><span class="pre"><span class="Identifier">saddr</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">saddrLen</span></span></tt>. Returned future will complete once one datagram has been received, and will return size of packet received.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L723" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L723" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="recvInto-procs-all">
- <div id="recvInto,AsyncFD,pointer,int">
- <dt><pre><span class="Keyword">proc</span> <a href="#recvInto%2CAsyncFD%2Cpointer%2Cint"><span class="Identifier">recvInto</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">buf</span><span class="Other">:</span> <a href="system.html#pointer"><span class="Identifier">pointer</span></a><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</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><a href="system.html#int"><span class="Identifier">int</span></a><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="Identifier">ValueError</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>
- <dd>
-
- Reads <strong>up to</strong> <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt> bytes from <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt> into <tt class="docutils literal"><span class="pre"><span class="Identifier">buf</span></span></tt>, which must at least be of that size. Returned future will complete once all the data requested is read, a part of the data has been read, or the socket has disconnected in which case the future will complete with a value of <tt class="docutils literal"><span class="pre"><span class="DecNumber">0</span></span></tt>.<div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Warning:</b></span>
- The <tt class="docutils literal"><span class="pre"><span class="Identifier">Peek</span></span></tt> socket flag is not supported on Windows.</div>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L567" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L567" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="register-procs-all">
- <div id="register,AsyncFD">
- <dt><pre><span class="Keyword">proc</span> <a href="#register%2CAsyncFD"><span class="Identifier">register</span></a><span class="Other">(</span><span class="Identifier">fd</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</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="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Registers <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt> with the dispatcher.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L372" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L372" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="runForever-procs-all">
- <div id="runForever">
- <dt><pre><span class="Keyword">proc</span> <a href="#runForever"><span class="Identifier">runForever</span></a><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="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">OSError</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">TimeEffect</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>
- <dd>
-
- Begins a never ending global dispatcher poll loop.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L2015" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L2015" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="send-procs-all">
- <div id="send,AsyncFD,pointer,int">
- <dt><pre><span class="Keyword">proc</span> <a href="#send%2CAsyncFD%2Cpointer%2Cint"><span class="Identifier">send</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">buf</span><span class="Other">:</span> <a href="system.html#pointer"><span class="Identifier">pointer</span></a><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</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><a href="system.html#void"><span class="Identifier">void</span></a><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="Identifier">ValueError</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>
- <dd>
-
- Sends <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt> bytes from <tt class="docutils literal"><span class="pre"><span class="Identifier">buf</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt>. The returned future will complete once all data has been sent.<div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Warning:</b></span>
- Use it with caution. If <tt class="docutils literal"><span class="pre"><span class="Identifier">buf</span></span></tt> refers to GC'ed object, you must use GC_ref/GC_unref calls to avoid early freeing of the buffer.</div>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L633" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L633" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="send,AsyncFD,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#send%2CAsyncFD%2Cstring"><span class="Identifier">send</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</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><a href="system.html#void"><span class="Identifier">void</span></a><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="Identifier">ValueError</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>
- <dd>
-
- Sends <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt>. The returned future will complete once all data has been sent.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1978" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1978" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="sendTo-procs-all">
- <div id="sendTo,AsyncFD,pointer,int,ptr.SockAddr,SockLen">
- <dt><pre><span class="Keyword">proc</span> <a href="#sendTo%2CAsyncFD%2Cpointer%2Cint%2Cptr.SockAddr%2CSockLen"><span class="Identifier">sendTo</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <a href="system.html#pointer"><span class="Identifier">pointer</span></a><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">saddr</span><span class="Other">:</span> <span class="Keyword">ptr</span> <a href="winlean.html#SockAddr"><span class="Identifier">SockAddr</span></a><span class="Other">;</span>
- <span class="Identifier">saddrLen</span><span class="Other">:</span> <a href="winlean.html#SockLen"><span class="Identifier">SockLen</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</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><a href="system.html#void"><span class="Identifier">void</span></a><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="Identifier">ValueError</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>
- <dd>
-
- Sends <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> to specified destination <tt class="docutils literal"><span class="pre"><span class="Identifier">saddr</span></span></tt>, using socket <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt>. The returned future will complete once all data has been sent.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L678" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L678" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="setGlobalDispatcher-procs-all">
- <div id="setGlobalDispatcher,sinkPDispatcher">
- <dt><pre><span class="Keyword">proc</span> <a href="#setGlobalDispatcher%2CsinkPDispatcher"><span class="Identifier">setGlobalDispatcher</span></a><span class="Other">(</span><span class="Identifier">disp</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <a href="asyncdispatch.html#PDispatcher"><span class="Identifier">PDispatcher</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L356" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L356" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="setInheritable-procs-all">
- <div id="setInheritable,AsyncFD,bool">
- <dt><pre><span class="Keyword">proc</span> <a href="#setInheritable%2CAsyncFD%2Cbool"><span class="Identifier">setInheritable</span></a><span class="Other">(</span><span class="Identifier">fd</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">inheritable</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</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>
- <dd>
-
- <p>Control whether a file handle can be inherited by child processes. Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt> on success.</p>
- <p>This procedure is not guaranteed to be available for all platforms. Test for availability with <a class="reference external" href="system.html#declared,untyped">declared()</a>.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L868" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L868" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="sleepAsync-procs-all">
- <div id="sleepAsync">
- <dt><pre><span class="Keyword">proc</span> <a href="#sleepAsync"><span class="Identifier">sleepAsync</span></a><span class="Other">(</span><span class="Identifier">ms</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> <span class="Operator">|</span> <a href="system.html#float"><span class="Identifier">float</span></a><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><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">)</span></pre></dt>
- <dd>
-
- Suspends the execution of the current async procedure for the next <tt class="docutils literal"><span class="pre"><span class="Identifier">ms</span></span></tt> milliseconds.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1920" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1920" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="trigger-procs-all">
- <div id="trigger,AsyncEvent">
- <dt><pre><span class="Keyword">proc</span> <a href="#trigger%2CAsyncEvent"><span class="Identifier">trigger</span></a><span class="Other">(</span><span class="Identifier">ev</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncEvent"><span class="Identifier">AsyncEvent</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="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Set event <tt class="docutils literal"><span class="pre"><span class="Identifier">ev</span></span></tt> to signaled state.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1113" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1113" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="unregister-procs-all">
- <div id="unregister,AsyncEvent">
- <dt><pre><span class="Keyword">proc</span> <a href="#unregister%2CAsyncEvent"><span class="Identifier">unregister</span></a><span class="Other">(</span><span class="Identifier">ev</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncEvent"><span class="Identifier">AsyncEvent</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="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Unregisters event <tt class="docutils literal"><span class="pre"><span class="Identifier">ev</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1118" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1118" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="unregister,AsyncFD">
- <dt><pre><span class="Keyword">proc</span> <a href="#unregister%2CAsyncFD"><span class="Identifier">unregister</span></a><span class="Other">(</span><span class="Identifier">fd</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Unregisters <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L875" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L875" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="waitFor-procs-all">
- <div id="waitFor,Future[T]">
- <dt><pre><span class="Keyword">proc</span> <a href="#waitFor%2CFuture%5BT%5D"><span class="Identifier">waitFor</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">fut</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="Identifier">T</span></pre></dt>
- <dd>
-
- <strong>Blocks</strong> the current thread until the specified future completes.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L2020" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L2020" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="withTimeout-procs-all">
- <div id="withTimeout,Future[T],int">
- <dt><pre><span class="Keyword">proc</span> <a href="#withTimeout%2CFuture%5BT%5D%2Cint"><span class="Identifier">withTimeout</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">fut</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">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> <span class="Identifier">owned</span><span class="Other">(</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#bool"><span class="Identifier">bool</span></a><span class="Other">]</span><span class="Other">)</span></pre></dt>
- <dd>
-
- <p>Returns a future which will complete once <tt class="docutils literal"><span class="pre"><span class="Identifier">fut</span></span></tt> completes or after <tt class="docutils literal"><span class="pre"><span class="Identifier">timeout</span></span></tt> milliseconds has elapsed.</p>
- <p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">fut</span></span></tt> completes first the returned future will hold true, otherwise, if <tt class="docutils literal"><span class="pre"><span class="Identifier">timeout</span></span></tt> milliseconds has elapsed first, the returned future will hold false.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncdispatch.nim#L1932" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncdispatch.nim#L1932" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- </div>
- </div>
- <div class="twelve-columns footer">
- <span class="nim-sprite"></span>
- <br>
- <small style="color: var(--hint);">Made with Nim. Generated: 2025-02-03 14:57:13 UTC</small>
- </div>
- </div>
- </div>
- <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
-
- </body>
- </html>
|