Janet 1.9.1-4ae3722 Documentation
(Other Versions: 1.8.1 1.7.0 1.6.0 1.5.1 1.5.0 1.4.0 1.3.1 )



thread/close thread/current thread/new thread/receive thread/send

thread/close cfunction
(thread/close thread)

Close a thread, unblocking it and ending communication with it. Note that closing a thread is idempotent and does not cancel the thread's operation. Returns nil.

thread/current cfunction

Get the current running thread.

thread/new cfunction
(thread/new func &opt capacity)

Start a new thread that will start immediately. If capacity is provided, that is how many messages can be stored in the thread's mailbox before blocking senders. The capacity must be between 1 and 65535 inclusive, and defaults to 10. Returns a handle to the new thread.

thread/receive cfunction
(thread/receive &opt timeout)

Get a message sent to this thread. If timeout is provided, an error will be thrown after the timeout has elapsed but no messages are received.

thread/send cfunction
(thread/send thread msg)

Send a message to the thread. This will never block and returns thread immediately. Will throw an error if there is a problem sending the message.