What is spawn() best used for? What are it's drawbacks? Are there alternatives in some cases?
Most often I use it to run things in the 'background'. I've read byond is single threaded, so things can only run in order regardless.
spawn(-1) proc_name() |
I use that a lot for my infinite loops, or loops that run for a long time. I also use it when I want to run a proc passively, but I don't want to wait on it to finish before proceeding.
proc |
Like that.
Use spawn(2) in Process 1
Process 2 activates
Process 2 finishes, 1 tick used
Process 3 activates
Process 3 finishes, 2 ticks now used
Process 1 comes back in now that 2 ticks are used
Process 1 finishes
Process 4 activates
Process 4 finishes