Janet 1.13.1-392d5d5 Documentation
(Other Versions: 1.12.2 1.11.1 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 (in seconds) is provided, an error will be thrown after the timeout has elapsed but no messages are received. The default timeout is 1 second, and math/inf cam be passed to turn off the timeout.
Community Examples

thread/send cfunction
(thread/send thread msgi &opt timeout)

Send a message to the thread. By default, the timeout is 1 second, but an optional timeout in seconds can be provided. Use math/inf for no timeout. Will throw an error if there is a problem sending the message.
Community Examples