[svn:parrot] r49432 - trunk/src

plobsing at svn.parrot.org plobsing at svn.parrot.org
Sun Oct 3 19:08:10 UTC 2010


Author: plobsing
Date: Sun Oct  3 19:08:09 2010
New Revision: 49432
URL: https://trac.parrot.org/parrot/changeset/49432

Log:
process events on sleep start even if parrot doesn't have threads

This isn't the best solution. the thread will execute all pending tasks and then sleep for the specified duration in stead of executing pending tasks during the sleep interval. But it does prevent coretest from hanging on t/pmc/timer.t on threadless platforms.

Modified:
   trunk/src/scheduler.c

Modified: trunk/src/scheduler.c
==============================================================================
--- trunk/src/scheduler.c	Sun Oct  3 16:17:38 2010	(r49431)
+++ trunk/src/scheduler.c	Sun Oct  3 19:08:09 2010	(r49432)
@@ -1009,26 +1009,29 @@
 Parrot_cx_schedule_sleep(PARROT_INTERP, FLOATVAL time, ARGIN_NULLOK(opcode_t *next))
 {
     ASSERT_ARGS(Parrot_cx_schedule_sleep)
-#ifdef PARROT_HAS_THREADS
-    Parrot_cond condition;
-    Parrot_mutex lock;
-    const FLOATVAL timer_end = time + Parrot_floatval_time();
-    struct timespec time_struct;
 
     /* Tell the scheduler runloop to wake, this is a good time to process
      * pending tasks. */
     Parrot_cx_runloop_wake(interp, interp->scheduler);
 
-    /* Tell this thread to sleep for the requested time. */
-    COND_INIT(condition);
-    MUTEX_INIT(lock);
-    LOCK(lock);
-    time_struct.tv_sec = (time_t) timer_end;
-    time_struct.tv_nsec = (long)((timer_end - time_struct.tv_sec)*1000.0f) *1000L*1000L;
-    COND_TIMED_WAIT(condition, lock, &time_struct);
-    UNLOCK(lock);
-    COND_DESTROY(condition);
-    MUTEX_DESTROY(lock);
+#ifdef PARROT_HAS_THREADS
+    {
+        Parrot_cond condition;
+        Parrot_mutex lock;
+        const FLOATVAL timer_end = time + Parrot_floatval_time();
+        struct timespec time_struct;
+
+        /* Tell this thread to sleep for the requested time. */
+        COND_INIT(condition);
+        MUTEX_INIT(lock);
+        LOCK(lock);
+        time_struct.tv_sec = (time_t) timer_end;
+        time_struct.tv_nsec = (long)((timer_end - time_struct.tv_sec)*1000.0f) *1000L*1000L;
+        COND_TIMED_WAIT(condition, lock, &time_struct);
+        UNLOCK(lock);
+        COND_DESTROY(condition);
+        MUTEX_DESTROY(lock);
+    }
 #else
     /* A more primitive, platform-specific, non-threaded form of sleep. */
     if (time > 1000) {


More information about the parrot-commits mailing list