Created
March 6, 2014 00:04
-
-
Save jsbattig/9379411 to your computer and use it in GitHub Desktop.
SvcBusThreadPoolTimer_init() fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int SvcBusThreadPoolTimer_init( SvcBusThreadPoolTimer* _this, SvcBusThreadPool* pool, SvcBusThreadPool_callback callback, void* context, unsigned int millis ) | |
{ | |
FILETIME FileDueTime; | |
ULARGE_INTEGER ulDueTime; | |
_this->timer = CreateThreadpoolTimer( &SvcBusThreadPoolTimer_TimerCallback, _this, &pool->pcbe ); | |
if( _this->timer == NULL ) | |
{ | |
return SVCBUS_THREADPOOL_ERROR; | |
} | |
_this->context = context; | |
_this->thread_id = 0; | |
_this->callback = callback; | |
/* notice in the following line of code the negative sign in front of millis casted to __int64. It's to make the SetThreadpoolTimer() API to trigger | |
the first timer relative to current datetime of the system. If using a positive value, it will be an absolute time in 100 nanosecond units since | |
January 1, 1601 (UTC) forcing us to obtain the current datetime and do the arithmetics */ | |
ulDueTime.QuadPart = -(__int64)millis * 10 /* 100 nanosecond increments per microsecond */ * 1000 /* microseconds per millisecond */; | |
FileDueTime.dwHighDateTime = ulDueTime.HighPart; | |
FileDueTime.dwLowDateTime = ulDueTime.LowPart; | |
SetThreadpoolTimer( _this->timer, &FileDueTime, millis, 0 ); | |
return SVCBUS_THREADPOOL_OK; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment