turbobadger
turbobadger copied to clipboard
Linux timer
This pull request is my preliminary implementation of linux timer and message queue handling. We use timerfd facility Linux kindly provides us with: (http://man7.org/linux/man-pages/man2/timerfd_create.2.html). Please comment on what you would like to be changed. I have seen some traces of "waking" the message queue? (it was dummy though) I think we would need interrupts to do this.
- For now the architecture is extremely simple: TBSystem now have two static variables: one to hold timer file descriptor, the second to hold timer state (fired or not). Upon calling TBSystem::PollEvents() the timer status is checked, and if it had fired, messages are processed accordingly. To function properly it requires to call PollEvents() in a loop as with glfwPollEvents(). There is no ansynchronicity. If it is desired, we could consider forking another thread to poll() (this is POSIX obviously, so this part would be portable) timer file and then set timer_state accordingly. Then the user would just need to check timer_status, without trying each time to read from a file, reducing the overhead.
- Initialization and shutdown of timer system was added to tb_core.cpp. I hope this is the right place.
- The pull request also contains integration of the system into Demo program on Linux. I tested it in various ways, and it seems to work.
Any update on this pull request? Would love to see this implemented.
Just an observation - this patch has an inconsistent (and incompatible) style and apparently strange newlines. Prolly needs to be cleaned up a bit.
I see no need to pollute the cross platform interface TBSystem with linux port implementation details. I would be OK with having Init/Shutdown there and call them for all platforms, but not the other stuff.
I haven't tested the code or looked into much details. I'm not very familiar with linux timer stuff. If it works and is cleaner i would probably merge it :)
I completely forgot about this PR, sorry and did not got any notifications for it.
If people are still interested in it, I can go back and clean it up, adjust it to architecture