use a timer for the LGMP host instead of a thread

This commit is contained in:
Geoffrey McRae
2020-04-24 20:34:58 +10:00
parent e7f088ef52
commit fdb9a9cca8
8 changed files with 111 additions and 28 deletions

View File

@@ -20,6 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#pragma once
#include <stdint.h>
#include <stdbool.h>
#if defined(_WIN32)
#include <windows.h>
@@ -28,6 +29,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <stdint.h>
#endif
typedef struct LGTimer LGTimer;
static inline uint64_t microtime()
{
#if defined(_WIN32)
@@ -64,3 +67,10 @@ static inline void nsleep(uint64_t ns)
nanosleep(&ts, NULL);
}
#endif
typedef bool (*LGTimerFn)(void * udata);
bool lgCreateTimer(const unsigned int intervalMS, LGTimerFn fn,
void * udata, LGTimer ** result);
void lgTimerDestroy(LGTimer * timer);