doc: flesh out tasks and channels
This commit is contained in:
parent
b571a342d7
commit
a8df25c497
|
@ -4180,7 +4180,57 @@ Returns a value representing the JSON string read from channel
|
|||
Teliva includes the well-known
|
||||
<a href='https://github.com/majek/lua-channels#readme'>lua-channels</a>
|
||||
library in module <code>task</code>. It also transparently starts up
|
||||
<code>task.scheduler</code> for all apps.
|
||||
<code>task.scheduler</code> for all apps. See sieve.tlv for a basic example.
|
||||
|
||||
<p>
|
||||
<hr><h3><a name="pdf-task.spawn"><code>task.spawn (fun, [...])</code></a></h3>
|
||||
|
||||
|
||||
<p>
|
||||
Run <code>fun</code> as a coroutine with given parameters. You should use this
|
||||
instead of <code>coroutine.create()</code>.
|
||||
|
||||
|
||||
<p>
|
||||
<hr><h3><a name="pdf-task.scheduler"><code>task.scheduler ()</code></a></h3>
|
||||
|
||||
|
||||
<p>
|
||||
Starts running any spawned tasks. You shouldn't need to ever call this from
|
||||
Teliva. The scheduler is always started for you.
|
||||
|
||||
|
||||
<p>
|
||||
<hr><h3><a name="pdf-Channel:new"><code>task.Channel:new ([size])</code></a></h3>
|
||||
|
||||
|
||||
<p>
|
||||
Create a new channel with given size (which defaults to 0).
|
||||
|
||||
|
||||
<p>
|
||||
<hr><h3><a name="pdf-channel:send"><code>channel:send (value)</code></a></h3>
|
||||
|
||||
|
||||
<p>
|
||||
Write <code>value</code> to a channel. Blocks the current coroutine if the
|
||||
channel is already full. (Channels with size 0 always block if there isn't
|
||||
already a coroutine trying to <code>recv()</code> from them.)
|
||||
|
||||
|
||||
<p>
|
||||
<hr><h3><a name="pdf-channel:recv"><code>channel:recv ()</code></a></h3>
|
||||
|
||||
|
||||
<p>
|
||||
Read a value from a channel. Blocks the current coroutine if the
|
||||
channel is empty and there isn't already a coroutine trying to
|
||||
<code>send()</code> to them.
|
||||
|
||||
|
||||
<p>
|
||||
Besides these, there are other primitives that have never been used in Teliva
|
||||
apps, but should still work. Please report if you try them out.
|
||||
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue