guint32
SleepEx (guint32 ms, gboolean alertable)
{
- struct timespec req;
int ms_quot, ms_rem;
int ret;
gpointer current_thread = NULL;
if (alertable) {
current_thread = get_current_thread_handle ();
- if (_wapi_thread_apc_pending (current_thread))
+ if (_wapi_thread_cur_apc_pending ())
return WAIT_IO_COMPLETION;
}
ms_quot = ms / 1000;
ms_rem = ms % 1000;
- req.tv_sec=ms_quot;
- req.tv_nsec=ms_rem*1000000;
-
#if defined (__linux__) && !defined(PLATFORM_ANDROID)
/* Use clock_nanosleep () to prevent time drifting problems when nanosleep () is interrupted by signals */
ret = clock_gettime (CLOCK_MONOTONIC, &start);
while (TRUE) {
ret = clock_nanosleep (CLOCK_MONOTONIC, TIMER_ABSTIME, &target, NULL);
- if (alertable && _wapi_thread_apc_pending (current_thread))
+ if (alertable && _wapi_thread_cur_apc_pending ())
return WAIT_IO_COMPLETION;
if (ret == 0)
}
#else
+ struct timespec req;
+
+ req.tv_sec=ms_quot;
+ req.tv_nsec=ms_rem*1000000;
again:
memset (&rem, 0, sizeof (rem));
ret=nanosleep(&req, &rem);
- if (alertable && _wapi_thread_apc_pending (current_thread))
+ if (alertable && _wapi_thread_cur_apc_pending ())
return WAIT_IO_COMPLETION;
if(ret==-1) {
gboolean
_wapi_thread_cur_apc_pending (void)
-{
- return _wapi_thread_apc_pending (get_current_thread_handle ());
-}
-
-gboolean
-_wapi_thread_apc_pending (gpointer handle)
{
WapiHandle_thread *thread;
- thread = lookup_thread (handle);
-
+ thread = lookup_thread (get_current_thread_handle ());
return thread->wait_handle == INTERRUPTION_REQUESTED_HANDLE;
}
* call the wait function again. This essentially means that the target thread will
* busy wait until it is ready to process the interruption.
*/
-void
-wapi_interrupt_thread (gpointer thread_handle)
-{
- gpointer wait_handle;
-
- wait_handle = wapi_prepare_interrupt_thread (thread_handle);
- wapi_finish_interrupt_thread (wait_handle);
-}
-
gpointer
wapi_prepare_interrupt_thread (gpointer thread_handle)
{
WapiHandle_thread *thread;
gpointer prev_handle, wait_handle;
- thread = lookup_thread (thread_handle);
+ thread = lookup_thread (thread_handle); /* FIXME this is wrong, move this whole thing to MonoThreads where it can be done lockfree */
while (TRUE) {
wait_handle = thread->wait_handle;