diff dwtx/core/internal/jobs/JobManager.d @ 167:862b05e0334a

Add a wrapper for Thread
author Frank Benoit <benoit@tionex.de>
date Tue, 09 Sep 2008 15:59:16 +0200
parents 9d0585bcb7aa
children c3583c6ec027
line wrap: on
line diff
--- a/dwtx/core/internal/jobs/JobManager.d	Mon Sep 08 01:01:30 2008 +0200
+++ b/dwtx/core/internal/jobs/JobManager.d	Tue Sep 09 15:59:16 2008 +0200
@@ -18,7 +18,7 @@
 import tango.text.convert.Format;
 import tango.time.WallClock;
 import tango.time.Time;
-import tango.core.Thread;
+import dwtx.dwtxhelper.JThread;
 import tango.text.convert.Format;
 
 //don't use ICU because this is used for debugging only (see bug 135785)
@@ -193,7 +193,7 @@
             msgBuf.append('-');
         }
         msgBuf.append('[');
-        msgBuf.append(Thread.getThis().toString());
+        msgBuf.append(JThread.currentThread().toString());
         msgBuf.append(']');
         msgBuf.append(msg);
         Stdout.formatln( "{}", msgBuf.toString());
@@ -466,7 +466,7 @@
      * @see dwtx.core.runtime.jobs.IJobManager#currentJob()
      */
     public Job currentJob() {
-        Thread current = Thread.getThis();
+        JThread current = JThread.currentThread();
         if (cast(Worker)current )
             return (cast(Worker) current).currentJob();
         synchronized (lock) {
@@ -550,7 +550,7 @@
             }
 
             for (int waitAttempts = 0; waitAttempts < 3; waitAttempts++) {
-                Thread.yield();
+                JThread.yield();
                 synchronized (lock) {
                     if (running.isEmpty())
                         break;
@@ -568,11 +568,11 @@
                     }
                 }
                 try {
-                    Thread.sleep(0.100);
+                    JThread.sleep(100);
                 } catch (InterruptedException e) {
                     //ignore
                 }
-                Thread.yield();
+                JThread.yield();
             }
 
             synchronized (lock) { // retrieve list of the jobs that are still running
@@ -773,7 +773,7 @@
             if (suspended && state !is Job.RUNNING)
                 return;
             //it's an error for a job to join itself
-            if (state is Job.RUNNING && job.getThread_package() is Thread.getThis())
+            if (state is Job.RUNNING && job.getThread_package() is JThread.currentThread())
                 throw new IllegalStateException("Job attempted to join itself"); //$NON-NLS-1$
             //the semaphore will be released when the job is done
             barrier = new Semaphore(null);
@@ -877,15 +877,14 @@
                     reportedWorkDone = actualWorkDone;
                     monitor.subTask(NLS.bind(JobMessages.jobs_waitFamSub, Integer.toString(jobsLeft)));
                 }
-                implMissing(__FILE__, __LINE__ );
-// DWT
-//                 if (Thread.interrupted())
-//                     throw new InterruptedException();
+
+                if (JThread.interrupted())
+                    throw new InterruptedException();
                 if (monitor.isCanceled())
                     throw new OperationCanceledException();
                 //notify hook to service pending syncExecs before falling asleep
                 lockManager.aboutToWait(null);
-                Thread.sleep(0.100);
+                JThread.sleep(100);
             }
         } finally {
             lockManager.aboutToRelease();
@@ -1300,7 +1299,7 @@
     /* non-Javadoc)
      * @see dwtx.core.runtime.jobs.IJobManager#transferRule()
      */
-    public void transferRule(ISchedulingRule rule, Thread destinationThread) {
+    public void transferRule(ISchedulingRule rule, JThread destinationThread) {
         implicitJobs.transfer(rule, destinationThread);
     }