Skip to content

Allows tick events to auto-requeue when registered as listeners - #2484

Closed
cppcooper wants to merge 5 commits into
DFHack:developfrom
cppcooper:em-tickevents
Closed

cppcooper wants to merge 5 commits into
DFHack:developfrom
cppcooper:em-tickevents

Conversation

@cppcooper

Copy link
Copy Markdown
Contributor

No description provided.

@myk002 myk002 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after this change, what will the options be for cpp and lua code to handle regular callbacks? will we be able to replace repeat-util with eventful?

Comment thread library/include/modules/EventManager.h
@cppcooper

cppcooper commented Jan 9, 2023 •

Copy link
Copy Markdown
Contributor Author

after this change, what will the options be for cpp and lua code to handle regular callbacks? will we be able to replace repeat-util with eventful?

It looks as though that script could easily be replaced, yes.

edit:

As for options, cpp will have the registerTick and registerListener available for tick events. Most use cases will likely be opting for the registerListener unless they want the event to only trigger once. For example: if they need to run some clean up code.

eventful on the other hand, doesn't have tick events integrated.. but shouldn't be difficult to do.

edit2:

So I've tried to integrate tick events to eventful. It needs a bit of testing, but I believe it has all the same boilerplate the other event types have (so it should work, unless I missed something). It will only rely on the registerListener the same as the others. Of course this precludes it from the other functionality available with registerTick. So if a callback needs to happen only once, the user would then need to unregister the listener inside their callback.

- converts `freq` and `eventHandler` (i.e. the callback) to `const`
- removes the non-const `when` from the hash computation
@cppcooper
cppcooper force-pushed the em-tickevents branch 2 times, most recently from 1a4914b to e2bc986 Compare March 16, 2023 19:55
@cppcooper

Copy link
Copy Markdown
Contributor Author

after this change, what will the options be for cpp and lua code to handle regular callbacks? will we be able to replace repeat-util with eventful?

As discussed on discord, there are a few technical challenges when bringing tick events to lua. So I reverted those changes.

I've included an updated channel-safely in this PR which uses the newly repeating tick events to perform some tasks. Additionally I had added a temporary event which repeated hourly and performed a test to ensure the tick listener events are refiring without any user effort. [test was successful]

@ab9rf

ab9rf commented Sep 22, 2026

Copy link
Copy Markdown
Member

This PR appears abandoned and code has drifted considerably since it was last touched.

@ab9rf ab9rf closed this Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants