From a8df25c49709421b2033b72371f9387c0c4c13a3 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 14 Mar 2022 09:56:07 -0700 Subject: doc: flesh out tasks and channels --- doc/manual.html | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/manual.html b/doc/manual.html index a0f485c..1f317af 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -4180,7 +4180,57 @@ Returns a value representing the JSON string read from channel Teliva includes the well-known lua-channels library in module task. It also transparently starts up -task.scheduler for all apps. +task.scheduler for all apps. See sieve.tlv for a basic example. + +

+


task.spawn (fun, [...])

+ + +

+Run fun as a coroutine with given parameters. You should use this +instead of coroutine.create(). + + +

+


task.scheduler ()

+ + +

+Starts running any spawned tasks. You shouldn't need to ever call this from +Teliva. The scheduler is always started for you. + + +

+


task.Channel:new ([size])

+ + +

+Create a new channel with given size (which defaults to 0). + + +

+


channel:send (value)

+ + +

+Write value 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 recv() from them.) + + +

+


channel:recv ()

+ + +

+Read a value from a channel. Blocks the current coroutine if the +channel is empty and there isn't already a coroutine trying to +send() to them. + + +

+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. -- cgit 1.4.1-2-gfad0