Well, 'a lot' sounds like an exaggeration. Reading the clock is different between Windows API and POSIX anyway. So for polling I typically write my own Linux version of the Windows GetTickCount() in conditional Linux code. The same could be done for scheduling a timer event, I suppose.Ras wrote:Sounds like a lot of platform dependent stuff. However, the code that interfaces threaded stdin scanning with the search is portable - if only because it's a total hack on every platform.
Code: Select all
#ifdef WIN32
# include <windows.h>
# include <io.h>
HANDLE process;
DWORD thread_id;
#else
# include <pthread.h>
# include <signal.h>
# define NO_ERROR 0
# include <sys/time.h>
int GetTickCount() // with thanks to Tord
{ struct timeval t; gettimeofday(&t, NULL); return t.tv_sec*1000 + t.tv_usec/1000; }
#endif