zorael / kameloso

IRC bot with Twitch support
Boost Software License 1.0
8 stars 3 forks source link

Implicit Fibers for generated wrappers of select top-level functions #176

Closed zorael closed 9 months ago

zorael commented 9 months ago

Plugins' top-level .setup, .initialise, .reload and .teardown functions have mixin-generated wrappers in the form of IRCPlugin.{setup,initialise,reload,teardown}. These are in place to expose said top-level functions to other parts of the program.

In many cases these functions need Fiber functionality, and ended up individually containing manual Fiber management.

This PR makes the generated wrappers instead always construct a Fiber and then call the original function from inside of it. It also removes the ad-hoc solutions from the plugins that were hitherto doing Fibers manually, to complete the migration.

This does not affect .tick, as it is by nature not meant to suspend by delaying or awaiting. Some handlers that would have been run too often (and created a disproportional number of Fibers) were also excluded, such as onAnyEvent-style handlers, and such being indiscriminately invoked on all IRCEvent.Type.CHAN events.