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

Threads

Index

thread/close thread/current thread/exit 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.
Community Examples

thread/current cfunction
(thread/current)

Get the current running thread.
Community Examples

thread/exit cfunction
(thread/exit &opt code)

Exit from the current thread. If no more threads are running, ends the process, but otherwise does not end the current process.
Community Examples

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

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. Can optionally provide flags to the new thread - supported flags are:
	:h - Start a heavyweight thread. This loads the core environment by default, so may use more memory initially. Messages may compress better, though.
	:a - Allow sending over registered abstract types to the new thread
	:c - Send over cfunction information to the new thread.
Returns a handle to the new thread.
Community Examples

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.
Community Examples

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.
Community Examples