Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Coroutiner: simple tool for creating, running, or learning about coroutines

edited April 26 in Code Sharing Posts: 1,284

This can do two things: it can make a resumable thread out of one table of functions, and it can take two tables of functions and run them as coroutines.

The principle could be expanded to cover any number of tables, but right now it just takes two.

It’s very simple and provides no dynamic access to, or manipulation of, the threads themselves as they are being run.

Tagged:

Comments

  • edited April 26 Posts: 1,284

    Update.

    Now the Coroutiner can take any number of tables containing any number of functions and run them each in alternating sequence.

    It is still limited in that there is no dynamic thread access. It only handles the function tables it is initialized with. But if you know exactly which sequence of functions you need to alternate between, this will make it easy to do that.

    It can also just take a single function table and turn it into a coroutine thread for you, independent of its own stored threads. Then you can use that individual thread in any way you want.

    The code is now very thoroughly commented, so it might be helpful to inspect it if you don’t know anything about coroutines and want to see them in action.

Sign In or Register to comment.