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

ComputerCraft Event System Flowchart

Started by KingofGamesYami, 02 April 2016 - 01:58 AM
KingofGamesYami #1
Posted 02 April 2016 - 03:58 AM
I decided to make a visual of the event system. It's not by any means perfect, but I'd like to say it's pretty nice.



Made with lucidchart.
Edited on 04 April 2016 - 12:52 AM
wilcomega #2
Posted 03 April 2016 - 12:40 AM
Could have used this when i was making blueframes :P/> this makes lifes easier
Lupus590 #3
Posted 03 April 2016 - 07:28 PM
This could be a handy image for learning how to use coroutines, or for anyone making a tutorial on the usage of coroutines (@BombBloke this may break up your wall of text quite nicely)
Bomb Bloke #4
Posted 03 April 2016 - 11:12 PM
It's a pretty good graphic. I assume you don't mind if I yoink it?
KingofGamesYami #5
Posted 03 April 2016 - 11:15 PM
Go ahead; however it'd be good to keep in mind the image updates if I make changes to the flowchart. I won't remove anything, but I am considering adding to it.

Actually, while we're on the subject: Is there anything in particular I should add?
Edited on 03 April 2016 - 11:02 PM
Bomb Bloke #6
Posted 04 April 2016 - 02:10 AM
I'd be inclined to expand on "waiting for an event" - you don't really do that if there're already events in the queue. There's also the matter of resuming other coroutines the manager may be handling.

You may also consider adding arrows for cases where os.pullEventRaw() is bypassed by calling coroutine.yield() directly. Adding columns for coroutine.yield() and coroutine.resume() may help you better visualise how data goes in/out of the coroutine.
KingofGamesYami #7
Posted 04 April 2016 - 02:47 AM
I have modified my graphic to better describe how waiting for events works, including a separate process which adds events to the queue as the occur.

I also added a part which shows at which point other coroutines are resumed; I'm not sure if that's adequate or if I should have a better indicator that this process happens for each one.

The arrows for coroutine.yield() have been added, however I did not add columns for yield / resume. I just can't visualize how that would work, in my mind they are essentially the same; an analogy I would use to describe them is the sides of a coin (heads/tails).

Finally, I added how errors work. This added a lot of stuff. Unfortunately I have lines that cross, I'll work on sorting that out without adding a lot of whitespace or making the arrows extremely ugly.
cmdpwnd #8
Posted 05 April 2016 - 04:13 AM
This makes life so much easier when writing coroutines! Actually with this much detail I actually think I could pretty easily write a non-coroutine program that still functions rather similarly to coroutines. ……. I think I will. hehe :)/>

Thank you so much for making this!