[io-layer] Remove _wapi_thread_apc_pending function
[mono.git] / mono / io-layer / wthreads.c
index d001da277c019304e996907bf15175b7a6479437..aff4e8f4662db4f4733fffc22d356bf86057eac0 100644 (file)
@@ -229,7 +229,6 @@ GetCurrentThreadId (void)
 guint32
 SleepEx (guint32 ms, gboolean alertable)
 {
-       struct timespec req;
        int ms_quot, ms_rem;
        int ret;
        gpointer current_thread = NULL;
@@ -244,7 +243,7 @@ SleepEx (guint32 ms, gboolean alertable)
        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;
        }
        
@@ -257,9 +256,6 @@ SleepEx (guint32 ms, gboolean alertable)
        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);
@@ -275,7 +271,7 @@ SleepEx (guint32 ms, gboolean alertable)
        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)
@@ -283,12 +279,16 @@ SleepEx (guint32 ms, gboolean alertable)
        }
 
 #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) {
@@ -315,17 +315,10 @@ Sleep(guint32 ms)
 
 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;
 }
 
@@ -341,22 +334,13 @@ _wapi_thread_apc_pending (gpointer 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;