iptux-src / iptux

A software for sharing in LAN
GNU General Public License v2.0
445 stars 130 forks source link

[refactor] introduce a new Corethread Event consume method #585

Closed lidaobing closed 6 months ago

lidaobing commented 6 months ago

Currently, the only way to consume corethread event is registering callback on CoreThread.signalEvent. Example:

https://github.com/iptux-src/iptux/blob/cf49769a0bb62e2deb63d23df115a508608dbde2/examples/count-bot/main.cpp#L47-L48

But it's not suitable for UI(which has its own mainloop). so we need to use an adaptor to queue it in the mainloop, which make things too complex. Example:

https://github.com/iptux-src/iptux/blob/cf49769a0bb62e2deb63d23df115a508608dbde2/src/iptux/EventAdaptor.cpp#L26-L29

we need to add some methods to corethread, to make the consumer easier to write.

CoreThread.CountEvent
CoreThread.HasEvent
CoreThread.PopEvent