4 ms·
What kind of tasks would said thread be concerned with? Delegation and I/O?
by awild 6y ago
What kind of tasks would said thread be concerned with? Delegation and I/O?
- bob1029 6y agoI am currently using it to drive timing of frame generation and processing of UI events (i.e. animations, cursor flashing, etc) in a custom 2d graphics engine. The API I currently have is: int RegisterTimer(int afterMicroseconds, Action action) void CancelTimer(int timerId) It is really nice having this level of timing resolution and consistency in such a simple interface. I can just assume that whatever action I set up for delayed execution is running precisely when I wanted it to (in practical terms).
- awild 6y agoIf understand that right you have a thread that only looks for now-open jobs and assigns them to workers? How do they receive their work? Funny enough, what you're describing is basically the timer api that was used in warcraft 3 scripting.
- magicalhippo 6y agoKeep in mind that by spinning, you're preventing the CPU from sleeping thus wasting a lot of energy. At the very least, make sure you stop spinning when the game loses focus.
- bob1029 6y agoFor reference, the domain of usage of this timer thread is in a server-side application. Clients do not have to run this. The server application handles many clients simultaneously, so cost of spinning is amortized across many users.