job send for experimental
Send a message to the mailbox of a job.
Signature
> job send {flags} (id)
Flags
--tag {int}: A tag for the message
Parameters
id: The id of the job to send the message to.
Input/output types:
| input | output |
|---|---|
| any | nothing |
Examples
Send a message from the main thread to a newly-spawned job
> let id = job spawn { job recv | save sent.txt }; 'hi' | job send $idSend a message from a newly-spawned job to the main thread (which always has an ID of 0)
> job spawn { sleep 1sec; 'hi' | job send 0 }; job recvNotes
This command sends a message to a background job, which can then read sent messages in a first-in-first-out fashion with job recv. When it does so, it may additionally specify a numeric filter tag, in which case it will only read messages sent with the exact same filter tag. In particular, the id 0 refers to the main/initial nushell thread.
A message can be any nushell value, and streams are always collected before being sent.
This command never blocks.