Skip to content
This repository was archived by the owner on Apr 23, 2023. It is now read-only.

Commit 5989fc2

Browse files
author
Jack Tang
committed
Release 0.2.2
1 parent d7d737d commit 5989fc2

File tree

2 files changed

+54
-7
lines changed

2 files changed

+54
-7
lines changed

docs/index.html

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ <h1 class="title">threadproxy</h1>
105105
<li><a class="reference" href="#ThreadNotFoundError"
106106
title="ThreadNotFoundError = object of ThreadProxyError
107107
threadName*: string"><wbr />Thread<wbr />Not<wbr />Found<wbr />Error<span class="attachedType"></span></a></li>
108+
<li><a class="reference" href="#ThreadUncleanableError"
109+
title="ThreadUncleanableError = object of ThreadProxyError
110+
threadName*: string"><wbr />Thread<wbr />Uncleanable<wbr />Error<span class="attachedType"></span></a></li>
108111
<li><a class="reference" href="#ReceiverNotFoundError"
109112
title="ReceiverNotFoundError = object of ThreadProxyError
110113
sender*: string
@@ -125,6 +128,12 @@ <h1 class="title">threadproxy</h1>
125128
<li><a class="reference" href="#PollConflictError"
126129
title="PollConflictError = object of ThreadProxyError
127130
threadName*: string"><wbr />Poll<wbr />Conflict<wbr />Error<span class="attachedType"></span></a></li>
131+
<li><a class="reference" href="#HandlerIsNilError"
132+
title="HandlerIsNilError = object of ThreadProxyError"><wbr />Handler<wbr />Is<wbr />Nil<wbr />Error<span class="attachedType"></span></a></li>
133+
<li><a class="reference" href="#ResponseError"
134+
title="ResponseError = object of ThreadProxyError
135+
action*: string
136+
errorMessage*: string"><wbr />Response<wbr />Error<span class="attachedType"></span></a></li>
128137
<li><a class="reference" href="#ThreadActionHandler"
129138
title="ThreadActionHandler = proc (data: JsonNode): Future[JsonNode] {.gcsafe.}"><wbr />Thread<wbr />Action<wbr />Handler<span class="attachedType"></span></a></li>
130139
<li><a class="reference" href="#ThreadDefaultActionHandler"
@@ -192,6 +201,8 @@ <h1 class="title">threadproxy</h1>
192201
title="pinToCpu(proxy: MainThreadProxy; name: string; cpu: Natural)"><wbr />pin<wbr />To<wbr />Cpu<span class="attachedType">MainThreadProxy</span></a></li>
193202
<li><a class="reference" href="#isThreadRunning%2CMainThreadProxy%2Cstring"
194203
title="isThreadRunning(proxy: MainThreadProxy; name: string): bool"><wbr />is<wbr />Thread<wbr />Running<span class="attachedType">MainThreadProxy</span></a></li>
204+
<li><a class="reference" href="#cleanThreads%2CMainThreadProxy"
205+
title="cleanThreads(proxy: MainThreadProxy): Future[void]"><wbr />clean<wbr />Threads<span class="attachedType">MainThreadProxy</span></a></li>
195206

196207
</ul>
197208
</li>
@@ -231,6 +242,15 @@ <h1><a class="toc-backref" href="#7">Types</a></h1>
231242

232243
Raised when operation on thread with name <tt class="docutils literal"><span class="pre">threadName</span></tt> cannot be found
233244

245+
</dd>
246+
<a id="ThreadUncleanableError"></a>
247+
<dt><pre><a href="threadproxy.html#ThreadUncleanableError"><span class="Identifier">ThreadUncleanableError</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="threadproxy.html#ThreadProxyError"><span class="Identifier">ThreadProxyError</span></a>
248+
<span class="Identifier">threadName</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
249+
</pre></dt>
250+
<dd>
251+
252+
Raised when thread cannot be clean-up
253+
234254
</dd>
235255
<a id="ReceiverNotFoundError"></a>
236256
<dt><pre><a href="threadproxy.html#ReceiverNotFoundError"><span class="Identifier">ReceiverNotFoundError</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="threadproxy.html#ThreadProxyError"><span class="Identifier">ThreadProxyError</span></a>
@@ -281,6 +301,24 @@ <h1><a class="toc-backref" href="#7">Types</a></h1>
281301

282302
Raised when poll() is called while ThreadProxy is running
283303

304+
</dd>
305+
<a id="HandlerIsNilError"></a>
306+
<dt><pre><a href="threadproxy.html#HandlerIsNilError"><span class="Identifier">HandlerIsNilError</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="threadproxy.html#ThreadProxyError"><span class="Identifier">ThreadProxyError</span></a>
307+
</pre></dt>
308+
<dd>
309+
310+
Raised when handler is nil
311+
312+
</dd>
313+
<a id="ResponseError"></a>
314+
<dt><pre><a href="threadproxy.html#ResponseError"><span class="Identifier">ResponseError</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="threadproxy.html#ThreadProxyError"><span class="Identifier">ThreadProxyError</span></a>
315+
<span class="Identifier">action</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
316+
<span class="Identifier">errorMessage</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
317+
</pre></dt>
318+
<dd>
319+
320+
Raised when the opposite failed to reply
321+
284322
</dd>
285323
<a id="ThreadActionHandler"></a>
286324
<dt><pre><a href="threadproxy.html#ThreadActionHandler"><span class="Identifier">ThreadActionHandler</span></a> <span class="Other">=</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">JsonNode</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">JsonNode</span><span class="Other">]</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">gcsafe</span></span><span class="Other">.}</span></span></pre></dt>
@@ -385,15 +423,15 @@ <h1><a class="toc-backref" href="#12">Procs</a></h1>
385423
</dd>
386424
<a id="on,ThreadProxy,string,ThreadActionHandler"></a>
387425
<dt><pre><span class="Keyword">proc</span> <a href="#on%2CThreadProxy%2Cstring%2CThreadActionHandler"><span class="Identifier">on</span></a><span class="Other">(</span><span class="Identifier">proxy</span><span class="Other">:</span> <a href="threadproxy.html#ThreadProxy"><span class="Identifier">ThreadProxy</span></a><span class="Other">;</span> <span class="Identifier">action</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">handler</span><span class="Other">:</span> <a href="threadproxy.html#ThreadActionHandler"><span class="Identifier">ThreadActionHandler</span></a><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
388-
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ActionConflictError</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><span class="Other">.}</span></span></pre></dt>
426+
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ActionConflictError</span><span class="Other">,</span> <span class="Identifier">HandlerIsNilError</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><span class="Other">.}</span></span></pre></dt>
389427
<dd>
390428

391429
Set <tt class="docutils literal"><span class="pre">handler</span></tt> for <tt class="docutils literal"><span class="pre">action</span></tt>
392430

393431
</dd>
394432
<a id="onDefault,ThreadProxy,ThreadDefaultActionHandler"></a>
395-
<dt><pre><span class="Keyword">proc</span> <a href="#onDefault%2CThreadProxy%2CThreadDefaultActionHandler"><span class="Identifier">onDefault</span></a><span class="Other">(</span><span class="Identifier">proxy</span><span class="Other">:</span> <a href="threadproxy.html#ThreadProxy"><span class="Identifier">ThreadProxy</span></a><span class="Other">;</span> <span class="Identifier">handler</span><span class="Other">:</span> <a href="threadproxy.html#ThreadDefaultActionHandler"><span class="Identifier">ThreadDefaultActionHandler</span></a><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
396-
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
433+
<dt><pre><span class="Keyword">proc</span> <a href="#onDefault%2CThreadProxy%2CThreadDefaultActionHandler"><span class="Identifier">onDefault</span></a><span class="Other">(</span><span class="Identifier">proxy</span><span class="Other">:</span> <a href="threadproxy.html#ThreadProxy"><span class="Identifier">ThreadProxy</span></a><span class="Other">;</span> <span class="Identifier">handler</span><span class="Other">:</span> <a href="threadproxy.html#ThreadDefaultActionHandler"><span class="Identifier">ThreadDefaultActionHandler</span></a><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
434+
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">HandlerIsNilError</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><span class="Other">.}</span></span></pre></dt>
397435
<dd>
398436

399437
Set default <tt class="docutils literal"><span class="pre">handler</span></tt> for all unhandled action
@@ -420,8 +458,8 @@ <h1><a class="toc-backref" href="#12">Procs</a></h1>
420458

421459
</dd>
422460
<a id="process,ThreadProxy"></a>
423-
<dt><pre><span class="Keyword">proc</span> <a href="#process%2CThreadProxy"><span class="Identifier">process</span></a><span class="Other">(</span><span class="Identifier">proxy</span><span class="Other">:</span> <a href="threadproxy.html#ThreadProxy"><span class="Identifier">ThreadProxy</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><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">KeyError</span><span class="Other">,</span>
424-
<span class="Identifier">FutureError</span><span class="Other">,</span> <span class="Identifier">DeadThreadError</span><span class="Other">,</span> <span class="Identifier">Defect</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><span class="Other">.}</span></span></pre></dt>
461+
<dt><pre><span class="Keyword">proc</span> <a href="#process%2CThreadProxy"><span class="Identifier">process</span></a><span class="Other">(</span><span class="Identifier">proxy</span><span class="Other">:</span> <a href="threadproxy.html#ThreadProxy"><span class="Identifier">ThreadProxy</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><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">Exception</span><span class="Other">,</span>
462+
<span class="Identifier">KeyError</span><span class="Other">,</span> <span class="Identifier">DeadThreadError</span><span class="Other">,</span> <span class="Identifier">FutureError</span><span class="Other">,</span> <span class="Identifier">Defect</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><span class="Other">.}</span></span></pre></dt>
425463
<dd>
426464

427465
Process one message on channel. Return false if channel is empty, otherwise true.
@@ -476,6 +514,15 @@ <h1><a class="toc-backref" href="#12">Procs</a></h1>
476514

477515
Check whether thread is running. Applicable only to threads created with <tt class="docutils literal"><span class="pre">createThread</span></tt>
478516

517+
</dd>
518+
<a id="cleanThreads,MainThreadProxy"></a>
519+
<dt><pre><span class="Keyword">proc</span> <a href="#cleanThreads%2CMainThreadProxy"><span class="Identifier">cleanThreads</span></a><span class="Other">(</span><span class="Identifier">proxy</span><span class="Other">:</span> <a href="threadproxy.html#MainThreadProxy"><span class="Identifier">MainThreadProxy</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span>
520+
<span class="Identifier">ThreadNotFoundError</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">,</span> <span class="Identifier">FutureError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">,</span>
521+
<span class="Identifier">DeadThreadError</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><span class="Other">.}</span></span></pre></dt>
522+
<dd>
523+
524+
Clean up resource of non-running threads
525+
479526
</dd>
480527

481528
</dl></div>
@@ -506,7 +553,7 @@ <h1><a class="toc-backref" href="#18">Templates</a></h1>
506553
<div class="twelve-columns footer">
507554
<span class="nim-sprite"></span>
508555
<br/>
509-
<small style="color: var(--hint);">Made with Nim. Generated: 2020-05-28 18:57:02 UTC</small>
556+
<small style="color: var(--hint);">Made with Nim. Generated: 2020-05-29 19:55:51 UTC</small>
510557
</div>
511558
</div>
512559
</div>

threadproxy.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "0.2.1"
3+
version = "0.2.2"
44
author = "Jack Tang"
55
description = "Simplify Nim Inter-Thread Communication"
66
license = "MIT"

0 commit comments

Comments
 (0)