This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ObloxCC's profile picture

Coroutine Manager

Started by ObloxCC, 18 February 2017 - 07:35 PM
ObloxCC #1
Posted 18 February 2017 - 08:35 PM
How will I go along creating a coroutine manager? I'm having some trouble switching between coroutines (both start, then then one continues without switching back to the other, also only one receives info from the event).
Lupus590 #2
Posted 18 February 2017 - 09:34 PM
Two things:
first, BBs guide to coroutines
second, have a look at how the built in coroutine manager works
H4X0RZ #3
Posted 18 February 2017 - 10:29 PM
Most of the time people ask how to write their own coroutine manager the standard parallel API is enough already. Have you tried parallel and are not satisfied with it?
ObloxCC #4
Posted 18 February 2017 - 10:59 PM
Most of the time people ask how to write their own coroutine manager the standard parallel API is enough already. Have you tried parallel and are not satisfied with it?

I have tried, and it just can't work in the way I need it too
H4X0RZ #5
Posted 19 February 2017 - 01:22 AM
Most of the time people ask how to write their own coroutine manager the standard parallel API is enough already. Have you tried parallel and are not satisfied with it?

I have tried, and it just can't work in the way I need it too

in addition to Lupus stuff here's a general idea of how a simple coroutine manager kinda works:
loop until every coroutine is dead -> fetch an event -> loop over every coroutine and check if has an event filter and is not dead; compare the event to the filter and if no filter is set or it fits the filter resume the coroutine with the unpacked event as arguments, save the return value as new filter -> repeat