The previous version was racy and could lead to crashes.
The timer could be deleted before the callback was called, making it execute on already freed memory
This new version is similar to Mac's. It spawns its own thread and uses pthread_cond_wait.
Care is taken for small timeouts to avoid races in the thread creation and timer destruction.
Signed-off-by: Nuno Lopes <nlopes@microsoft.com>
- remove unused variables and class fields
- add support for gcc 4.5 & clang's __builtin_unreachable
- fix 2 bugs related to strict aliasing
- remove a few unused function parameters
Signed-off-by: Nuno Lopes <t-nclaud@microsoft.com>