# HG changeset patch # User Frank Benoit # Date 1220968756 -7200 # Node ID 862b05e0334a596a71a1c7a44ef67d9af62de6bf # Parent e5dd0081ccba178b15214c9771cb2b46b361aebc Add a wrapper for Thread diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/internal/jobs/Deadlock.d --- a/dwtx/core/internal/jobs/Deadlock.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/internal/jobs/Deadlock.d Tue Sep 09 15:59:16 2008 +0200 @@ -12,7 +12,7 @@ *******************************************************************************/ module dwtx.core.internal.jobs.Deadlock; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwt.dwthelper.utils; @@ -26,13 +26,13 @@ */ class Deadlock { //all the threads which are involved in the deadlock - private Thread[] threads; + private JThread[] threads; //the thread whose locks will be suspended to resolve deadlock - private Thread candidate; + private JThread candidate; //the locks that will be suspended private ISchedulingRule[] locks; - public this(Thread[] threads, ISchedulingRule[] locks, Thread candidate) { + public this(JThread[] threads, ISchedulingRule[] locks, JThread candidate) { this.threads = threads; this.locks = locks; this.candidate = candidate; @@ -42,11 +42,11 @@ return locks; } - public Thread getCandidate() { + public JThread getCandidate() { return candidate; } - public Thread[] getThreads() { + public JThread[] getThreads() { return threads; } } diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/internal/jobs/DeadlockDetector.d --- a/dwtx/core/internal/jobs/DeadlockDetector.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/internal/jobs/DeadlockDetector.d Tue Sep 09 15:59:16 2008 +0200 @@ -12,7 +12,7 @@ *******************************************************************************/ module dwtx.core.internal.jobs.DeadlockDetector; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import tango.io.Stdout; import tango.text.convert.Format; @@ -101,9 +101,9 @@ * are actually deadlocked with the current thread. * Add the threads that form deadlock to the deadlockedThreads list. */ - private bool addCycleThreads(ArrayList deadlockedThreads, Thread next) { + private bool addCycleThreads(ArrayList deadlockedThreads, JThread next) { //get the thread that block the given thread from running - Thread[] blocking = blockingThreads(next); + JThread[] blocking = blockingThreads(next); //if the thread is not blocked by other threads, then it is not part of a deadlock if (blocking.length is 0) return false; @@ -128,7 +128,7 @@ /** * Get the thread(s) that own the lock this thread is waiting for. */ - private Thread[] blockingThreads(Thread current) { + private JThread[] blockingThreads(JThread current) { //find the lock this thread is waiting for ISchedulingRule lock = cast(ISchedulingRule) getWaitingLock(current); return getThreadsOwningLock(lock); @@ -167,7 +167,7 @@ * Returns true IFF the matrix contains a row for the given thread. * (meaning the given thread either owns locks or is waiting for locks) */ - bool contains(Thread t) { + bool contains(JThread t) { return lockThreads.contains(t); } @@ -200,7 +200,7 @@ /** * Returns all the locks owned by the given thread */ - private Object[] getOwnedLocks(Thread current) { + private Object[] getOwnedLocks(JThread current) { ArrayList ownedLocks = new ArrayList(1); int index = indexOf(current, false); @@ -216,7 +216,7 @@ /** * Returns an array of threads that form the deadlock (usually 2). */ - private Thread[] getThreadsInDeadlock(Thread cause) { + private JThread[] getThreadsInDeadlock(JThread cause) { ArrayList deadlockedThreads = new ArrayList(2); /** * if the thread that caused deadlock doesn't own any locks, then it is not part @@ -225,15 +225,15 @@ if (ownsLocks(cause)) deadlockedThreads.add(cause); addCycleThreads(deadlockedThreads, cause); - return arraycast!(Thread)( deadlockedThreads.toArray()); + return arraycast!(JThread)( deadlockedThreads.toArray()); } /** * Returns the thread(s) that own the given lock. */ - private Thread[] getThreadsOwningLock(ISchedulingRule rule) { + private JThread[] getThreadsOwningLock(ISchedulingRule rule) { if (rule is null) - return new Thread[0]; + return new JThread[0]; int lockIndex = indexOf(rule, false); ArrayList blocking = new ArrayList(1); for (int i = 0; i < graph.length; i++) { @@ -244,13 +244,13 @@ Stdout.formatln(Format("Lock {} is involved in deadlock but is not owned by any thread.", rule )); //$NON-NLS-1$ //$NON-NLS-2$ if ((blocking.size() > 1) && (cast(ILock)rule ) && (JobManager.DEBUG_LOCKS)) Stdout.formatln(Format("Lock {} is owned by more than 1 thread, but it is not a rule.", rule )); //$NON-NLS-1$ //$NON-NLS-2$ - return arraycast!(Thread)( blocking.toArray()); + return arraycast!(JThread)( blocking.toArray()); } /** * Returns the lock the given thread is waiting for. */ - private Object getWaitingLock(Thread current) { + private Object getWaitingLock(JThread current) { int index = indexOf(current, false); //find the lock that this thread is waiting for for (int j = 0; j < graph[index].length; j++) { @@ -279,7 +279,7 @@ * Returns the index of the given thread in the thread array. If the thread * is not present in the array, it is added to the end. */ - private int indexOf(Thread owner, bool add) { + private int indexOf(JThread owner, bool add) { int index = lockThreads.indexOf(owner); if ((index < 0) && add) { lockThreads.add(owner); @@ -299,7 +299,7 @@ /** * The given lock was acquired by the given thread. */ - void lockAcquired(Thread owner, ISchedulingRule lock) { + void lockAcquired(JThread owner, ISchedulingRule lock) { int lockIndex = indexOf(lock, true); int threadIndex = indexOf(owner, true); if (resize) @@ -333,18 +333,18 @@ /** * The given lock was released by the given thread. Update the graph. */ - void lockReleased(Thread owner, ISchedulingRule lock) { + void lockReleased(JThread owner, ISchedulingRule lock) { int lockIndex = indexOf(lock, false); int threadIndex = indexOf(owner, false); //make sure the lock and thread exist in the graph if (threadIndex < 0) { if (JobManager.DEBUG_LOCKS) - Stdout.formatln("[lockReleased] Lock {} was already released by thread {}", lock, owner.name()); //$NON-NLS-1$ //$NON-NLS-2$ + Stdout.formatln("[lockReleased] Lock {} was already released by thread {}", lock, owner.getName()); //$NON-NLS-1$ //$NON-NLS-2$ return; } if (lockIndex < 0) { if (JobManager.DEBUG_LOCKS) - Stdout.formatln("[lockReleased] Thread {} already released lock {}", owner.name(), lock); //$NON-NLS-1$ //$NON-NLS-2$ + Stdout.formatln("[lockReleased] Thread {} already released lock {}", owner.getName(), lock); //$NON-NLS-1$ //$NON-NLS-2$ return; } //if this lock was suspended, set it to NO_STATE @@ -358,7 +358,7 @@ if ((lock.isConflicting(cast(ISchedulingRule) locks.get(j))) || (!(cast(ILock)lock ) && !(cast(ILock)locks.get(j)) && (graph[threadIndex][j] > NO_STATE))) { if (graph[threadIndex][j] is NO_STATE) { if (JobManager.DEBUG_LOCKS) - Stdout.formatln("[lockReleased] More releases than acquires for thread {} and lock {}", owner.name(), lock); //$NON-NLS-1$ //$NON-NLS-2$ + Stdout.formatln("[lockReleased] More releases than acquires for thread {} and lock {}", owner.getName(), lock); //$NON-NLS-1$ //$NON-NLS-2$ } else { graph[threadIndex][j]--; } @@ -373,18 +373,18 @@ * The given scheduling rule is no longer used because the job that invoked it is done. * Release this rule regardless of how many times it was acquired. */ - void lockReleasedCompletely(Thread owner, ISchedulingRule rule) { + void lockReleasedCompletely(JThread owner, ISchedulingRule rule) { int ruleIndex = indexOf(rule, false); int threadIndex = indexOf(owner, false); //need to make sure that the given thread and rule were not already removed from the graph if (threadIndex < 0) { if (JobManager.DEBUG_LOCKS) - Stdout.formatln("[lockReleasedCompletely] Lock {} was already released by thread {}", rule, owner.name()); //$NON-NLS-1$ //$NON-NLS-2$ + Stdout.formatln("[lockReleasedCompletely] Lock {} was already released by thread {}", rule, owner.getName()); //$NON-NLS-1$ //$NON-NLS-2$ return; } if (ruleIndex < 0) { if (JobManager.DEBUG_LOCKS) - Stdout.formatln("[lockReleasedCompletely] Thread {} already released lock {}", owner.name(), rule); //$NON-NLS-1$ //$NON-NLS-2$ + Stdout.formatln("[lockReleasedCompletely] Thread {} already released lock {}", owner.getName(), rule); //$NON-NLS-1$ //$NON-NLS-2$ return; } /** @@ -403,7 +403,7 @@ * The given thread could not get the given lock and is waiting for it. * Update the graph. */ - Deadlock lockWaitStart(Thread client, ISchedulingRule lock) { + Deadlock lockWaitStart(JThread client, ISchedulingRule lock) { setToWait(client, lock, false); int lockIndex = indexOf(lock, false); int[] temp = new int[lockThreads.size()]; @@ -411,15 +411,15 @@ if (!checkWaitCycles(temp, lockIndex)) return null; //there is a deadlock in the graph - Thread[] threads = getThreadsInDeadlock(client); - Thread candidate = resolutionCandidate(threads); + JThread[] threads = getThreadsInDeadlock(client); + JThread candidate = resolutionCandidate(threads); ISchedulingRule[] locksToSuspend = realLocksForThread(candidate); Deadlock deadlock = new Deadlock(threads, locksToSuspend, candidate); //find a thread whose locks can be suspended to resolve the deadlock if (JobManager.DEBUG_LOCKS) reportDeadlock(deadlock); if (JobManager.DEBUG_DEADLOCK) - throw new IllegalStateException(Format("Deadlock detected. Caused by thread {}.", client.name())); //$NON-NLS-1$ + throw new IllegalStateException(Format("Deadlock detected. Caused by thread {}.", client.getName())); //$NON-NLS-1$ // Update the graph to indicate that the locks will now be suspended. // To indicate that the lock will be suspended, we set the thread to wait for the lock. // When the lock is forced to be released, the entry will be cleared. @@ -432,13 +432,13 @@ * The given thread has stopped waiting for the given lock. * Update the graph. */ - void lockWaitStop(Thread owner, ISchedulingRule lock) { + void lockWaitStop(JThread owner, ISchedulingRule lock) { int lockIndex = indexOf(lock, false); int threadIndex = indexOf(owner, false); //make sure the thread and lock exist in the graph if (threadIndex < 0) { if (JobManager.DEBUG_LOCKS) - Stdout.formatln("Thread {} was already removed.", owner.name() ); //$NON-NLS-1$ //$NON-NLS-2$ + Stdout.formatln("Thread {} was already removed.", owner.getName() ); //$NON-NLS-1$ //$NON-NLS-2$ return; } if (lockIndex < 0) { @@ -447,7 +447,7 @@ return; } if (graph[threadIndex][lockIndex] !is WAITING_FOR_LOCK) - Assert.isTrue(false, Format("Thread {} was not waiting for lock {} so it could not time out.", owner.name(), (cast(Object)lock).toString())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + Assert.isTrue(false, Format("Thread {} was not waiting for lock {} so it could not time out.", owner.getName(), (cast(Object)lock).toString())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ graph[threadIndex][lockIndex] = NO_STATE; reduceGraph(threadIndex, lock); } @@ -455,7 +455,7 @@ /** * Returns true IFF the given thread owns a single lock */ - private bool ownsLocks(Thread cause) { + private bool ownsLocks(JThread cause) { int threadIndex = indexOf(cause, false); for (int j = 0; j < graph[threadIndex].length; j++) { if (graph[threadIndex][j] > NO_STATE) @@ -468,7 +468,7 @@ * Returns true IFF the given thread owns a single real lock. * A real lock is a lock that can be suspended. */ - private bool ownsRealLocks(Thread owner) { + private bool ownsRealLocks(JThread owner) { int threadIndex = indexOf(owner, false); for (int j = 0; j < graph[threadIndex].length; j++) { if (graph[threadIndex][j] > NO_STATE) { @@ -484,7 +484,7 @@ * Return true IFF this thread owns rule locks (i.e. implicit locks which * cannot be suspended) */ - private bool ownsRuleLocks(Thread owner) { + private bool ownsRuleLocks(JThread owner) { int threadIndex = indexOf(owner, false); for (int j = 0; j < graph[threadIndex].length; j++) { if (graph[threadIndex][j] > NO_STATE) { @@ -500,7 +500,7 @@ * Returns an array of real locks that are owned by the given thread. * Real locks are locks that implement the ILock interface and can be suspended. */ - private ISchedulingRule[] realLocksForThread(Thread owner) { + private ISchedulingRule[] realLocksForThread(JThread owner) { int threadIndex = indexOf(owner, false); ArrayList ownedLocks = new ArrayList(1); for (int j = 0; j < graph[threadIndex].length; j++) { @@ -607,14 +607,14 @@ * Adds a 'deadlock detected' message to the log with a stack trace. */ private void reportDeadlock(Deadlock deadlock) { - String msg = "Deadlock detected. All locks owned by thread " ~ deadlock.getCandidate().name() ~ " will be suspended."; //$NON-NLS-1$ //$NON-NLS-2$ + String msg = "Deadlock detected. All locks owned by thread " ~ deadlock.getCandidate().getName() ~ " will be suspended."; //$NON-NLS-1$ //$NON-NLS-2$ MultiStatus main = new MultiStatus(JobManager.PI_JOBS, JobManager.PLUGIN_ERROR, msg, new IllegalStateException()); - Thread[] threads = deadlock.getThreads(); + JThread[] threads = deadlock.getThreads(); for (int i = 0; i < threads.length; i++) { Object[] ownedLocks = getOwnedLocks(threads[i]); Object waitLock = getWaitingLock(threads[i]); StringBuffer buf = new StringBuffer("Thread "); //$NON-NLS-1$ - buf.append(threads[i].name()); + buf.append(threads[i].getName()); buf.append(" has locks: "); //$NON-NLS-1$ for (int j = 0; j < ownedLocks.length; j++) { buf.append(Format("{}",ownedLocks[j])); @@ -654,7 +654,7 @@ * Get the thread whose locks can be suspended. (i.e. all locks it owns are * actual locks and not rules). Return the first thread in the array by default. */ - private Thread resolutionCandidate(Thread[] candidates) { + private JThread resolutionCandidate(JThread[] candidates) { //first look for a candidate that has no scheduling rules for (int i = 0; i < candidates.length; i++) { if (!ownsRuleLocks(candidates[i])) @@ -672,7 +672,7 @@ /** * The given thread is waiting for the given lock. Update the graph. */ - private void setToWait(Thread owner, ISchedulingRule lock, bool suspend) { + private void setToWait(JThread owner, ISchedulingRule lock, bool suspend) { bool needTransfer = false; /** * if we are adding an entry where a thread is waiting on a scheduling rule, @@ -706,7 +706,7 @@ sb.append("\n"); for (int i = 0; i < graph.length; i++) { sb.append(" "); - sb.append( (cast(Thread) lockThreads.get(i)).name() ); + sb.append( (cast(JThread) lockThreads.get(i)).getName() ); sb.append(" : "); for (int j = 0; j < graph[i].length; j++) { sb.append(" "); diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/internal/jobs/ImplicitJobs.d --- a/dwtx/core/internal/jobs/ImplicitJobs.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/internal/jobs/ImplicitJobs.d Tue Sep 09 15:59:16 2008 +0200 @@ -13,7 +13,7 @@ module dwtx.core.internal.jobs.ImplicitJobs; import tango.text.convert.Format; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import tango.io.Stdout; import dwt.dwthelper.utils; import dwtx.dwtxhelper.Collection; @@ -65,7 +65,7 @@ void begin(ISchedulingRule rule, IProgressMonitor monitor, bool suspend) { if (JobManager.DEBUG_BEGIN_END) JobManager.debug_(Format("Begin rule: {}", rule)); //$NON-NLS-1$ - final Thread getThis = Thread.getThis(); + final JThread getThis = JThread.currentThread(); ThreadJob threadJob; synchronized (this) { threadJob = cast(ThreadJob) threadJobs.get(getThis); @@ -98,7 +98,7 @@ if (threadJob.acquireRule) { //no need to re-acquire any locks because the thread did not wait to get this lock if (manager.runNow_package(threadJob)) - manager.getLockManager().addLockThread(Thread.getThis(), rule); + manager.getLockManager().addLockThread(JThread.currentThread(), rule); else threadJob = threadJob.joinRun(monitor); } @@ -124,7 +124,7 @@ synchronized void end(ISchedulingRule rule, bool resume) { if (JobManager.DEBUG_BEGIN_END) JobManager.debug_(Format("End rule: {}", rule)); //$NON-NLS-1$ - ThreadJob threadJob = cast(ThreadJob) threadJobs.get(Thread.getThis()); + ThreadJob threadJob = cast(ThreadJob) threadJobs.get(JThread.currentThread()); if (threadJob is null) Assert.isLegal(rule is null, Format("endRule without matching beginRule: {}", rule)); //$NON-NLS-1$ else if (threadJob.pop(rule)) { @@ -138,7 +138,7 @@ * @param lastJob The last job to run in this thread */ void endJob(InternalJob lastJob) { - final Thread getThis = Thread.getThis(); + final JThread getThis = JThread.currentThread(); IStatus error; synchronized (this) { ThreadJob threadJob = cast(ThreadJob) threadJobs.get(getThis); @@ -161,7 +161,7 @@ } private void endThreadJob(ThreadJob threadJob, bool resume) { - Thread getThis = Thread.getThis(); + JThread getThis = JThread.currentThread(); //clean up when last rule scope exits threadJobs.remove(getThis); ISchedulingRule rule = threadJob.getRule(); @@ -251,11 +251,11 @@ /** * Implements IJobManager#transferRule(ISchedulingRule, Thread) */ - synchronized void transfer(ISchedulingRule rule, Thread destinationThread) { + synchronized void transfer(ISchedulingRule rule, JThread destinationThread) { //nothing to do for null if (rule is null) return; - Thread getThis = Thread.getThis(); + JThread getThis = JThread.currentThread(); //nothing to do if transferring to the same thread if (getThis is destinationThread) return; diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/internal/jobs/InternalJob.d --- a/dwtx/core/internal/jobs/InternalJob.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/internal/jobs/InternalJob.d Tue Sep 09 15:59:16 2008 +0200 @@ -13,6 +13,7 @@ module dwtx.core.internal.jobs.InternalJob; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.JThread; import dwtx.dwtxhelper.Collection; import dwtx.core.runtime.Assert; @@ -29,7 +30,6 @@ import dwtx.core.internal.jobs.JobManager; import dwtx.core.internal.jobs.ObjectMap; -import tango.core.Thread; import tango.text.convert.Format; /** @@ -128,7 +128,7 @@ /* * The thread that is currently running this job */ - private /+volatile+/ Thread thread = null; + private /+volatile+/ JThread thread = null; protected this(String name) { Assert.isNotNull(name); @@ -293,10 +293,10 @@ /* (non-javadoc) * @see Job.getThread */ - protected Thread getThread() { + protected JThread getThread() { return thread; } - package Thread getThread_package() { + package JThread getThread_package() { return getThread(); } @@ -564,10 +564,10 @@ /* (non-javadoc) * @see Job.setThread */ - protected void setThread(Thread thread) { + protected void setThread(JThread thread) { this.thread = thread; } - package void setThread_package(Thread thread) { + package void setThread_package(JThread thread) { setThread(thread); } diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/internal/jobs/JobManager.d --- 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); } diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/internal/jobs/JobMessages.d --- a/dwtx/core/internal/jobs/JobMessages.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/internal/jobs/JobMessages.d Tue Sep 09 15:59:16 2008 +0200 @@ -11,7 +11,7 @@ **********************************************************************/ module dwtx.core.internal.jobs.JobMessages; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import tango.io.Stdout; import tango.time.WallClock; import tango.text.convert.TimeStamp; @@ -41,6 +41,7 @@ // } public static void reloadMessages() { + implMissing(__FILE__,__LINE__); // NLS.initializeMessages(BUNDLE_NAME, import(BUNDLE_NAME~".properties")); } @@ -53,7 +54,7 @@ char[30] buf; buffer.append(tango.text.convert.TimeStamp.format( buf, WallClock.now())); buffer.append(" - ["); //$NON-NLS-1$ - buffer.append(Thread.getThis().name()); + buffer.append(JThread.currentThread().getName()); buffer.append("] "); //$NON-NLS-1$ buffer.append(message); Stdout.formatln(buffer.toString()); diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/internal/jobs/LockManager.d --- a/dwtx/core/internal/jobs/LockManager.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/internal/jobs/LockManager.d Tue Sep 09 15:59:16 2008 +0200 @@ -12,7 +12,7 @@ *******************************************************************************/ module dwtx.core.internal.jobs.LockManager; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwt.dwthelper.utils; import dwtx.dwtxhelper.Collection; @@ -115,7 +115,7 @@ /* (non-Javadoc) * Method declared on LockListener */ - public bool aboutToWait(Thread lockOwner) { + public bool aboutToWait(JThread lockOwner) { if (lockListener is null) return false; try { @@ -131,7 +131,7 @@ /** * This thread has just acquired a lock. Update graph. */ - void addLockThread(Thread thread, ISchedulingRule lock) { + void addLockThread(JThread thread, ISchedulingRule lock) { if (locks is null) return; try { @@ -146,7 +146,7 @@ /** * This thread has just been refused a lock. Update graph and check for deadlock. */ - void addLockWaitThread(Thread thread, ISchedulingRule lock) { + void addLockWaitThread(JThread thread, ISchedulingRule lock) { if (locks is null) return; try { @@ -220,13 +220,13 @@ public bool isLockOwner() { //all job threads have to be treated as lock owners because UI thread //may try to join a job - Thread current = Thread.getThis(); + JThread current = JThread.currentThread(); if (cast(Worker)current ) return true; if (locks is null) return false; synchronized (locks) { - return locks.contains(Thread.getThis()); + return locks.contains(JThread.currentThread()); } } @@ -240,7 +240,7 @@ /** * Releases all the acquires that were called on the given rule. Needs to be called only once. */ - void removeLockCompletely(Thread thread, ISchedulingRule rule) { + void removeLockCompletely(JThread thread, ISchedulingRule rule) { if (locks is null) return; try { @@ -255,7 +255,7 @@ /** * This thread has just released a lock. Update graph. */ - void removeLockThread(Thread thread, ISchedulingRule lock) { + void removeLockThread(JThread thread, ISchedulingRule lock) { try { synchronized (locks) { locks.lockReleased(thread, lock); @@ -268,7 +268,7 @@ /** * This thread has just stopped waiting for a lock. Update graph. */ - void removeLockWaitThread(Thread thread, ISchedulingRule lock) { + void removeLockWaitThread(JThread thread, ISchedulingRule lock) { try { synchronized (locks) { locks.lockWaitStop(thread, lock); @@ -281,7 +281,7 @@ /** * Resumes all the locks that were suspended while this thread was waiting to acquire another lock. */ - void resumeSuspendedLocks(Thread owner) { + void resumeSuspendedLocks(JThread owner) { LockState[] toResume; synchronized (suspendedLocks) { Stack prevLocks = cast(Stack) suspendedLocks.get(owner); diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/internal/jobs/OrderedLock.d --- a/dwtx/core/internal/jobs/OrderedLock.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/internal/jobs/OrderedLock.d Tue Sep 09 15:59:16 2008 +0200 @@ -13,7 +13,7 @@ module dwtx.core.internal.jobs.OrderedLock; import tango.text.convert.Format; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import tango.io.Stdout; import dwt.dwthelper.utils; @@ -53,7 +53,7 @@ /** * The thread of the operation that currently owns the lock. */ - private /+volatile+/ Thread currentOperationThread; + private /+volatile+/ JThread currentOperationThread; /** * Records the number of successive acquires in the same * thread. The lock is released only when the depth @@ -116,13 +116,13 @@ if (semaphore is null) return true; if (DEBUG) - Stdout.formatln("[{}] Operation waiting to be executed... ", Thread.getThis(), this); //$NON-NLS-1$ //$NON-NLS-2$ + Stdout.formatln("[{}] Operation waiting to be executed... ", JThread.currentThread(), this); //$NON-NLS-1$ //$NON-NLS-2$ success = doAcquire(semaphore, delay); - manager.resumeSuspendedLocks(Thread.getThis()); + manager.resumeSuspendedLocks(JThread.currentThread()); if (DEBUG && success) - Stdout.formatln("[{}] Operation started... ", Thread.getThis(), this); //$NON-NLS-1$ //$NON-NLS-2$ + Stdout.formatln("[{}] Operation started... ", JThread.currentThread(), this); //$NON-NLS-1$ //$NON-NLS-2$ else if (DEBUG) - Stdout.formatln("[{}] Operation timed out... ", Thread.getThis(), this); //$NON-NLS-1$ //$NON-NLS-2$ + Stdout.formatln("[{}] Operation timed out... ", JThread.currentThread(), this); //$NON-NLS-1$ //$NON-NLS-2$ return success; } @@ -133,9 +133,9 @@ private synchronized bool attempt() { //return true if we already own the lock //also, if nobody is waiting, grant the lock immediately - if ((currentOperationThread is Thread.getThis()) || (currentOperationThread is null && operations.isEmpty())) { + if ((currentOperationThread is JThread.currentThread()) || (currentOperationThread is null && operations.isEmpty())) { depth++; - setCurrentOperationThread(Thread.getThis()); + setCurrentOperationThread(JThread.currentThread()); return true; } return false; @@ -154,7 +154,7 @@ * otherwise a new semaphore will be created, enqueued, and returned. */ private synchronized Semaphore createSemaphore() { - return attempt() ? null : enqueue(new Semaphore(Thread.getThis())); + return attempt() ? null : enqueue(new Semaphore(JThread.currentThread())); } /** @@ -179,12 +179,12 @@ semaphore = createSemaphore(); if (semaphore is null) return true; - manager.addLockWaitThread(Thread.getThis(), this); + manager.addLockWaitThread(JThread.currentThread(), this); try { success = semaphore.acquire(delay); } catch (InterruptedException e) { if (DEBUG) - Stdout.formatln(Format("[{}] Operation interrupted while waiting... :-|", Thread.getThis())); //$NON-NLS-1$ //$NON-NLS-2$ + Stdout.formatln(Format("[{}] Operation interrupted while waiting... :-|", JThread.currentThread())); //$NON-NLS-1$ //$NON-NLS-2$ throw e; } if (success) { @@ -192,7 +192,7 @@ updateCurrentOperation(); } else { removeFromQueue(semaphore); - manager.removeLockWaitThread(Thread.getThis(), this); + manager.removeLockWaitThread(JThread.currentThread(), this); } return success; } @@ -278,7 +278,7 @@ * If newThread is null, release this lock from its previous owner. * If newThread is not null, grant this lock to newThread. */ - private void setCurrentOperationThread(Thread newThread) { + private void setCurrentOperationThread(JThread newThread) { if ((currentOperationThread !is null) && (newThread is null)) manager.removeLockThread(currentOperationThread, this); this.currentOperationThread = newThread; @@ -313,6 +313,6 @@ */ private synchronized void updateCurrentOperation() { operations.dequeue(); - setCurrentOperationThread(Thread.getThis()); + setCurrentOperationThread(JThread.currentThread()); } } diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/internal/jobs/Semaphore.d --- a/dwtx/core/internal/jobs/Semaphore.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/internal/jobs/Semaphore.d Tue Sep 09 15:59:16 2008 +0200 @@ -12,7 +12,7 @@ *******************************************************************************/ module dwtx.core.internal.jobs.Semaphore; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import tango.core.sync.Mutex; import tango.core.sync.Condition; import dwt.dwthelper.utils; @@ -21,12 +21,12 @@ public class Semaphore { protected long notifications; - protected Thread runnable; + protected JThread runnable; private Mutex mutex; private Condition condition; - public this(Thread runnable) { + public this(JThread runnable) { mutex = new Mutex; condition = new Condition(mutex); this.runnable = runnable; diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/internal/jobs/ThreadJob.d --- a/dwtx/core/internal/jobs/ThreadJob.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/internal/jobs/ThreadJob.d Tue Sep 09 15:59:16 2008 +0200 @@ -15,7 +15,7 @@ import dwt.dwthelper.utils; import tango.text.convert.Format; import tango.io.Stdout; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import tango.core.sync.Mutex; import tango.core.sync.Condition; @@ -178,7 +178,7 @@ throw new OperationCanceledException(); //check if there is a blocking thread before waiting InternalJob blockingJob = manager.findBlockingJob_package(this); - Thread blocker = blockingJob is null ? null : blockingJob.getThread_package(); + JThread blocker = blockingJob is null ? null : blockingJob.getThread_package(); ThreadJob result = this; try { //just return if lock listener decided to grant immediate access @@ -186,7 +186,7 @@ return this; try { waitStart(monitor, blockingJob); - final Thread getThis = Thread.getThis(); + final JThread getThis = JThread.currentThread(); while (true) { if (isCanceled(monitor)) throw new OperationCanceledException(); @@ -322,7 +322,7 @@ */ private void waitEnd(IProgressMonitor monitor) { final LockManager lockManager = manager.getLockManager(); - final Thread getThis = Thread.getThis(); + final JThread getThis = JThread.currentThread(); if (isRunning()) { lockManager.addLockThread(getThis, getRule()); //need to re-acquire any locks that were suspended while this thread was blocked on the rule @@ -340,7 +340,7 @@ * @param blockingJob The job that is blocking this thread, or null */ private void waitStart(IProgressMonitor monitor, InternalJob blockingJob) { - manager.getLockManager().addLockWaitThread(Thread.getThis(), getRule()); + manager.getLockManager().addLockWaitThread(JThread.currentThread(), getRule()); isBlocked = true; manager.reportBlocked(monitor, blockingJob); } diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/internal/jobs/Worker.d --- a/dwtx/core/internal/jobs/Worker.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/internal/jobs/Worker.d Tue Sep 09 15:59:16 2008 +0200 @@ -12,7 +12,7 @@ *******************************************************************************/ module dwtx.core.internal.jobs.Worker; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import tango.text.convert.Format; import dwt.dwthelper.utils; @@ -32,15 +32,15 @@ * A worker thread processes jobs supplied to it by the worker pool. When * the worker pool gives it a null job, the worker dies. */ -public class Worker : Thread { +public class Worker : JThread { //worker number used for debugging purposes only private static int nextWorkerNumber = 0; private /+volatile+/ InternalJob currentJob_; private final WorkerPool pool; public this(WorkerPool pool) { - super(&run); - this.name = Format("Worker-{}", nextWorkerNumber++); //$NON-NLS-1$ + super(); + this.setName( Format("Worker-{}", nextWorkerNumber++)); //$NON-NLS-1$ this.pool = pool; //set the context loader to avoid leaking the current context loader //for the thread that spawns this worker (bug 98376) @@ -60,8 +60,8 @@ return new Status(IStatus.ERROR, JobManager.PI_JOBS, JobManager.PLUGIN_ERROR, message, t); } - public void run() { - this.priority((PRIORITY_MAX-PRIORITY_MIN)/2); // DWT normal priority + public override void run() { + this.setPriority(NORM_PRIORITY); try { while ((currentJob_ = pool.startJob_package(this)) !is null) { currentJob_.setThread_package(this); @@ -80,10 +80,7 @@ // result = handleException(currentJob_, e); } finally { //clear interrupted state for this thread - implMissing( __FILE__, __LINE__ ); -// DWT -// Thread.interrupted(); - + JThread.interrupted(); //result must not be null if (result is null) diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/internal/jobs/WorkerPool.d --- a/dwtx/core/internal/jobs/WorkerPool.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/internal/jobs/WorkerPool.d Tue Sep 09 15:59:16 2008 +0200 @@ -12,7 +12,7 @@ *******************************************************************************/ module dwtx.core.internal.jobs.WorkerPool; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import tango.core.sync.Mutex; import tango.core.sync.Condition; import tango.text.convert.Format; @@ -125,7 +125,7 @@ //do not become the owners of the same rule in the graph if ((job.getRule_package() !is null) && !(cast(ThreadJob)job )) { //remove any locks this thread may be owning on that rule - manager.getLockManager().removeLockCompletely(Thread.getThis(), job.getRule_package()); + manager.getLockManager().removeLockCompletely(JThread.currentThread(), job.getRule_package()); } manager.endJob_package(job, result, true); //ensure this thread no longer owns any scheduling rules @@ -174,7 +174,7 @@ //create a thread if all threads are busy if (busyThreads >= numThreads) { Worker worker = new Worker(this); - worker.isDaemon(isDaemon); + worker.setDaemon(isDaemon); add(worker); if (JobManager.DEBUG) JobManager.debug_(Format("worker added to pool: {}", worker)); //$NON-NLS-1$ @@ -277,7 +277,7 @@ if ((job.getRule() !is null) && !(cast(ThreadJob)job )) { //don't need to re-aquire locks because it was not recorded in the graph //that this thread waited to get this rule - manager.getLockManager().addLockThread(Thread.getThis(), job.getRule()); + manager.getLockManager().addLockThread(JThread.currentThread(), job.getRule()); } //see if we need to wake another worker if (manager.sleepHint_package() <= 0) diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/runtime/jobs/IJobManager.d --- a/dwtx/core/runtime/jobs/IJobManager.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/runtime/jobs/IJobManager.d Tue Sep 09 15:59:16 2008 +0200 @@ -23,7 +23,7 @@ import dwtx.core.runtime.jobs.LockListener; import dwtx.core.runtime.jobs.ProgressProvider; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; /** * The job manager provides facilities for scheduling, querying, and maintaining jobs @@ -407,7 +407,7 @@ * @param destinationThread The new owner for the transferred rule. * @since 3.1 */ - public void transferRule(ISchedulingRule rule, Thread destinationThread); + public void transferRule(ISchedulingRule rule, JThread destinationThread); /** * Resumes scheduling of all sleeping jobs in the given family. This method diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/runtime/jobs/Job.d --- a/dwtx/core/runtime/jobs/Job.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/runtime/jobs/Job.d Tue Sep 09 15:59:16 2008 +0200 @@ -12,7 +12,7 @@ *******************************************************************************/ module dwtx.core.runtime.jobs.Job; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwt.dwthelper.utils; import dwtx.core.internal.jobs.InternalJob; @@ -335,7 +335,7 @@ * @return the thread this job is running in, or null * if this job is not running or the thread is unknown. */ - public final Thread getThread() { + public final JThread getThread() { return super.getThread(); } @@ -609,7 +609,7 @@ * @see #ASYNC_FINISH * @see #run(IProgressMonitor) */ - public final void setThread(Thread thread) { + public final void setThread(JThread thread) { super.setThread(thread); } diff -r e5dd0081ccba -r 862b05e0334a dwtx/core/runtime/jobs/LockListener.d --- a/dwtx/core/runtime/jobs/LockListener.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/core/runtime/jobs/LockListener.d Tue Sep 09 15:59:16 2008 +0200 @@ -12,7 +12,7 @@ *******************************************************************************/ module dwtx.core.runtime.jobs.LockListener; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwt.dwthelper.utils; import dwtx.core.internal.jobs.JobManager; @@ -49,7 +49,7 @@ * @return true if the thread should be granted immediate access, * and false if it should wait for the lock to be available */ - public bool aboutToWait(Thread lockOwner) { + public bool aboutToWait(JThread lockOwner) { return false; } diff -r e5dd0081ccba -r 862b05e0334a dwtx/dwtxhelper/JThread.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwtx/dwtxhelper/JThread.d Tue Sep 09 15:59:16 2008 +0200 @@ -0,0 +1,122 @@ +module dwtx.dwtxhelper.JThread; + +import tango.core.Thread; +import dwt.dwthelper.utils; + +class JThread { + + private Thread thread; + private Runnable runnable; + + private alias ThreadLocal!(JThread) TTLS; + private static TTLS tls; + + public static const int MAX_PRIORITY = 10; + public static const int MIN_PRIORITY = 1; + public static const int NORM_PRIORITY = 5; + + private static TTLS getTls(){ + if( tls is null ){ + synchronized( JThread.classinfo ){ + if( tls is null ){ + tls = new TTLS(); + } + } + } + return tls; + } + + public this(){ + thread = new Thread(&internalRun); + } + public this( void delegate() dg ){ + thread = new Thread(&internalRun); + runnable = dgRunnable( dg ); + } + public this(Runnable runnable){ + thread = new Thread(&internalRun); + this.runnable = runnable; + } + public this(Runnable runnable, String name){ + thread = new Thread(&internalRun); + this.runnable = runnable; + thread.name = name; + } + public this(String name){ + thread = new Thread(&internalRun); + thread.name = name; + } + + public void start(){ + thread.start(); + } + + public static JThread currentThread(){ + return getTls().val(); + } + public int getPriority() { + return (thread.priority-Thread.PRIORITY_MIN) * (MAX_PRIORITY-MIN_PRIORITY) / (Thread.PRIORITY_MAX-Thread.PRIORITY_MIN) + MIN_PRIORITY; + } + public void setPriority( int newPriority ) { + thread.priority( (newPriority-MIN_PRIORITY) * (Thread.PRIORITY_MAX-Thread.PRIORITY_MIN) / (MAX_PRIORITY-MIN_PRIORITY) +Thread.PRIORITY_MIN ); + } + + private void internalRun(){ + getTls().val( this ); + if( runnable !is null ){ + runnable.run(); + } + else { + run(); + } + } + + public bool isAlive(){ + return thread.isRunning(); + } + + public bool isDaemon() { + return thread.isDaemon(); + } + + public void join(){ + thread.join(); + } + + public void setDaemon(bool on) { + thread.isDaemon(on); + } + + public void setName(String name){ + thread.name = name; + } + public String getName(){ + return thread.name; + } + + void interrupt() { + implMissing(__FILE__,__LINE__); + } + + static bool interrupted() { + implMissing(__FILE__,__LINE__); + return false; + } + + public void run(){ + // default impl, do nothing + } + public static void sleep( int time ){ + Thread.sleep(time/1000.0); + } + public Thread nativeThread(){ + return thread; + } + public override char[] toString(){ + return "JThread "~thread.name; + } + public static void yield(){ + Thread.yield(); + } +} + diff -r e5dd0081ccba -r 862b05e0334a dwtx/dwtxhelper/Timer.d --- a/dwtx/dwtxhelper/Timer.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/dwtxhelper/Timer.d Tue Sep 09 15:59:16 2008 +0200 @@ -2,7 +2,7 @@ import dwtx.dwtxhelper.TimerTask; import tango.util.container.CircularList; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import tango.core.sync.Mutex; import tango.core.sync.Condition; import tango.time.Time; @@ -12,7 +12,7 @@ alias CircularList!( TimerTask ) ListType; - private Thread thread; + private JThread thread; private ListType schedules; private Mutex mutex; private Condition cond; @@ -26,8 +26,8 @@ cond = new Condition( mutex ); schedules = new ListType(); - thread = new Thread( &run ); - thread.isDaemon = isDaemon; + thread = new JThread( &run ); + thread.setDaemon( isDaemon ); thread.start(); } private void run(){ diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/action/ActionContributionItem.d --- a/dwtx/jface/action/ActionContributionItem.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/action/ActionContributionItem.d Tue Sep 09 15:59:16 2008 +0200 @@ -51,7 +51,7 @@ import dwt.dwthelper.utils; import dwt.dwthelper.Runnable; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import tango.io.Stdout; /** @@ -187,18 +187,12 @@ if (isVisible() && widget !is null) { Display display = widget.getDisplay(); - if (display.getThread() is Thread.getThis()) { + if (display.getThread() is JThread.currentThread().nativeThread()) { update(e.getProperty()); } else { - display.asyncExec(new class(e) Runnable { - PropertyChangeEvent e_; - this(PropertyChangeEvent e__){ - e_=e__; - } - public void run() { - update(e_.getProperty()); - } - }); + display.asyncExec(dgRunnable( (PropertyChangeEvent e_) { + update(e_.getProperty()); + }, e)); } } diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/fieldassist/ContentProposalAdapter.d --- a/dwtx/jface/fieldassist/ContentProposalAdapter.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/fieldassist/ContentProposalAdapter.d Tue Sep 09 15:59:16 2008 +0200 @@ -51,7 +51,7 @@ import dwt.dwthelper.utils; import dwt.dwthelper.Runnable; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; static import tango.text.Text; import tango.io.Stdout; import tango.text.convert.Format; @@ -936,7 +936,7 @@ pendingDescriptionUpdate = true; try { - Thread.sleep( POPUP_DELAY / 1000.0 ); + JThread.sleep( POPUP_DELAY ); } catch (InterruptedException e) { } @@ -978,7 +978,7 @@ }); } }; - Thread t = new Thread(&r.run); + JThread t = new JThread(r); t.start(); } } @@ -2021,7 +2021,7 @@ public void run(){ receivedKeyDown = false; try { - Thread.sleep(autoActivationDelay); + JThread.sleep(autoActivationDelay); } catch (InterruptedException e) { } if (!isValid() || receivedKeyDown) { @@ -2034,7 +2034,7 @@ }); } }; - Thread t = new Thread(&r.run); + JThread t = new JThread(r); t.start(); } else { // Since we do not sleep, we must open the popup diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/internal/text/link/contentassist/AdditionalInfoController2.d --- a/dwtx/jface/internal/text/link/contentassist/AdditionalInfoController2.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/internal/text/link/contentassist/AdditionalInfoController2.d Tue Sep 09 15:59:16 2008 +0200 @@ -25,7 +25,7 @@ import dwtx.jface.internal.text.link.contentassist.ContentAssistant2; // packageimport import dwt.dwthelper.utils; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwt.events.SelectionEvent; import dwt.events.SelectionListener; @@ -42,7 +42,6 @@ import dwtx.jface.text.contentassist.ICompletionProposalExtension3; - /** * Displays the additional information available for a completion proposal. * @@ -73,7 +72,7 @@ /** The proposal table */ private Table fProposalTable; /** The thread controlling the delayed display of the additional info */ - private Thread fThread; + private JThread fThread; /** Indicates whether the display delay has been reset */ private bool fIsReset= false; /** Object to synchronize display thread and table selection changes */ @@ -122,7 +121,7 @@ synchronized (fThreadAccess) { if (fThread !is null) fThread.interrupt(); - fThread= new Thread(this, ContentAssistMessages.getString("InfoPopup.info_delay_timer_name")); //$NON-NLS-1$ + fThread= new JThread(this, ContentAssistMessages.getString("InfoPopup.info_delay_timer_name")); //$NON-NLS-1$ fStartSignal= new Object(); synchronized (fStartSignal) { @@ -199,7 +198,7 @@ synchronized (fThreadAccess) { // only null fThread if it is us! - if (Thread.currentThread() is fThread) + if (JThread.currentThread() is fThread) fThread= null; } } diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/internal/text/link/contentassist/ContentAssistant2.d --- a/dwtx/jface/internal/text/link/contentassist/ContentAssistant2.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/internal/text/link/contentassist/ContentAssistant2.d Tue Sep 09 15:59:16 2008 +0200 @@ -24,7 +24,7 @@ import dwt.dwthelper.utils; import dwtx.dwtxhelper.Collection; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwt.DWT; import dwt.DWTError; @@ -230,7 +230,7 @@ */ class AutoAssistListener : VerifyKeyListener, Runnable { - private Thread fThread; + private JThread fThread; private bool fIsReset= false; private Object fMutex= new Object(); private int fShowStyle; diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/operation/IThreadListener.d --- a/dwtx/jface/operation/IThreadListener.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/operation/IThreadListener.d Tue Sep 09 15:59:16 2008 +0200 @@ -13,7 +13,7 @@ module dwtx.jface.operation.IThreadListener; import dwt.dwthelper.utils; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; /** * A thread listener is an object that is interested in receiving notifications @@ -29,5 +29,5 @@ * * @param thread The new thread */ - public void threadChange(Thread thread); + public void threadChange(JThread thread); } diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/operation/ModalContext.d --- a/dwtx/jface/operation/ModalContext.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/operation/ModalContext.d Tue Sep 09 15:59:16 2008 +0200 @@ -27,7 +27,7 @@ import dwt.dwthelper.utils; import dwt.dwthelper.Runnable; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import tango.io.Stdout; /** @@ -67,7 +67,7 @@ /** * Thread which runs the modal context. */ - private static class ModalContextThread : Thread { + private static class ModalContextThread : JThread { /** * The operation to be run. */ @@ -98,7 +98,7 @@ * * @since 3.1 */ - private Thread callingThread; + private JThread callingThread; /** * Creates a new modal context. @@ -113,18 +113,18 @@ */ private this(IRunnableWithProgress operation, IProgressMonitor monitor, Display display) { - super(&run2); //$NON-NLS-1$ + super(); //$NON-NLS-1$ Assert.isTrue(monitor !is null && display !is null); runnable = operation; progressMonitor = new AccumulatingProgressMonitor(monitor, display); this.display = display; - this.callingThread = Thread.getThis(); + this.callingThread = JThread.currentThread(); } /* * (non-Javadoc) Method declared on Thread. */ - public /+override+/ void run2() { + public override void run() { try { if (runnable !is null) { runnable.run(progressMonitor); @@ -156,11 +156,9 @@ // Make sure that all events in the asynchronous event queue // are dispatched. - display.syncExec(new class() Runnable { - public void run() { - // do nothing - } - }); + display.syncExec(dgRunnable( { + // do nothing + } )); // Stop event dispatching continueEventDispatching = false; @@ -276,7 +274,7 @@ * context is active. */ private static ModalContextThread getCurrentModalContextThread() { - Thread t = Thread.getThis(); + JThread t = JThread.currentThread(); if ( auto r = cast(ModalContextThread)t ) { return r; } @@ -307,7 +305,7 @@ * @return true if the given thread is running a modal * context, false if not */ - public static bool isModalContextThread(Thread thread) { + public static bool isModalContextThread(JThread thread) { return (cast(ModalContextThread)thread) !is null; } @@ -428,7 +426,7 @@ * the {@link Thread} being switched to */ static Exception invokeThreadListener(IThreadListener listener, - Thread switchingThread) { + JThread switchingThread) { try { listener.threadChange(switchingThread); // } catch (ThreadDeath e) { diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/text/TextViewer.d --- a/dwtx/jface/text/TextViewer.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/text/TextViewer.d Tue Sep 09 15:59:16 2008 +0200 @@ -156,7 +156,7 @@ import dwtx.dwtxhelper.Collection; import dwtx.dwtxhelper.regex; import tango.text.convert.Format; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwt.DWT; import dwt.custom.LineBackgroundEvent; diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/text/TextViewerHoverManager.d --- a/dwtx/jface/text/TextViewerHoverManager.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/text/TextViewerHoverManager.d Tue Sep 09 15:59:16 2008 +0200 @@ -154,7 +154,7 @@ import dwtx.jface.text.ITypedRegion; // packageimport import dwt.dwthelper.utils; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwt.custom.StyledText; import dwt.events.MouseEvent; @@ -192,7 +192,7 @@ /** The text viewer */ private TextViewer fTextViewer; /** The hover information computation thread */ - private Thread fThread; + private JThread fThread; /** The stopper of the computation thread */ private ITextListener fStopper; /** Internal monitor */ diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/text/contentassist/AdditionalInfoController.d --- a/dwtx/jface/text/contentassist/AdditionalInfoController.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/text/contentassist/AdditionalInfoController.d Tue Sep 09 15:59:16 2008 +0200 @@ -45,7 +45,7 @@ import dwtx.jface.text.contentassist.JFaceTextMessages; // packageimport import dwt.dwthelper.utils; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwt.events.SelectionEvent; import dwt.events.SelectionListener; @@ -259,7 +259,7 @@ } /** The timer thread. */ - private const Thread fThread; + private const JThread fThread; /** The currently waiting / active task. */ private Task fTask; diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/text/contentassist/ContentAssistant.d --- a/dwtx/jface/text/contentassist/ContentAssistant.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/text/contentassist/ContentAssistant.d Tue Sep 09 15:59:16 2008 +0200 @@ -48,7 +48,7 @@ import dwt.dwthelper.utils; import dwtx.dwtxhelper.Collection; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwt.DWT; import dwt.DWTError; @@ -276,7 +276,7 @@ */ protected class AutoAssistListener : KeyAdapter , KeyListener, Runnable, VerifyKeyListener { - private Thread fThread; + private JThread fThread; private bool fIsReset= false; private Object fMutex= new Object(); private int fShowStyle; diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/text/reconciler/AbstractReconciler.d --- a/dwtx/jface/text/reconciler/AbstractReconciler.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/text/reconciler/AbstractReconciler.d Tue Sep 09 15:59:16 2008 +0200 @@ -27,7 +27,7 @@ import dwt.dwthelper.utils; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwtx.core.runtime.Assert; import dwtx.core.runtime.IProgressMonitor; @@ -69,7 +69,7 @@ * Background thread for the reconciling activity. */ class BackgroundThread { - Thread thread; + JThread thread; /** Has the reconciler been canceled. */ private bool fCanceled= false; @@ -99,7 +99,7 @@ public bool isAlive(){ return thread.isRunning(); } - public Thread getThread(){ + public JThread getThread(){ return thread; } /** diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/text/source/AnnotationModel.d --- a/dwtx/jface/text/source/AnnotationModel.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/text/source/AnnotationModel.d Tue Sep 09 15:59:16 2008 +0200 @@ -77,7 +77,7 @@ import dwt.dwthelper.utils; import dwtx.dwtxhelper.Collection; import tango.core.Exception; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwtx.core.runtime.Assert; import dwtx.jface.text.AbstractDocument; diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/text/source/projection/ProjectionSummary.d --- a/dwtx/jface/text/source/projection/ProjectionSummary.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/text/source/projection/ProjectionSummary.d Tue Sep 09 15:59:16 2008 +0200 @@ -25,7 +25,7 @@ import dwt.dwthelper.utils; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; import dwtx.dwtxhelper.Collection; @@ -55,7 +55,7 @@ private class Summarizer { - Thread thread; + JThread thread; private bool fReset= true; /** diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/viewers/deferred/BackgroundContentProvider.d --- a/dwtx/jface/viewers/deferred/BackgroundContentProvider.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/viewers/deferred/BackgroundContentProvider.d Tue Sep 09 15:59:16 2008 +0200 @@ -29,7 +29,7 @@ import dwtx.jface.viewers.IFilter; import dwt.dwthelper.utils; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; /** * Contains the algorithm for performing background sorting and filtering in a virtual @@ -141,7 +141,7 @@ private ConcurrentTableUpdator updator; private IProgressMonitor sortingProgressMonitor; - private Thread sortThread = null; + private JThread sortThread = null; private /+volatile+/ FastProgressReporter sortMon; @@ -475,12 +475,12 @@ */ private bool sortScheduled = false; - private final class SortThread : Thread { + private final class SortThread : JThread { private this(String name) { - super(/+name+/); + super(name); } - public /+override+/ void run() { + public override void run() { loop: while (true) { synchronized (lock) { sortScheduled = false; @@ -514,8 +514,8 @@ if (!sortThreadStarted) { sortThreadStarted = true; sortThread = new SortThread(SORTING); - sortThread.isDaemon = true; - sortThread.priority = sortThread.priority - 1; + sortThread.setDaemon( true ); + sortThread.setPriority( sortThread.getPriority() - 1 ); sortThread.start(); } } diff -r e5dd0081ccba -r 862b05e0334a dwtx/jface/window/ToolTip.d --- a/dwtx/jface/window/ToolTip.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/jface/window/ToolTip.d Tue Sep 09 15:59:16 2008 +0200 @@ -35,7 +35,7 @@ import dwt.dwthelper.utils; import dwtx.dwtxhelper.Collection; import dwt.dwthelper.Runnable; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; /** * This class gives implementors to provide customized tooltips for any control. * @@ -495,7 +495,7 @@ display.asyncExec(dgRunnable( delegate(Display display_, Event newEvent_) { if (IS_OSX) { try { - Thread.sleep(0.300); + JThread.sleep(300); } catch (InterruptedException e) { } diff -r e5dd0081ccba -r 862b05e0334a dwtx/ui/internal/forms/widgets/BusyIndicator.d --- a/dwtx/ui/internal/forms/widgets/BusyIndicator.d Mon Sep 08 01:01:30 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/BusyIndicator.d Tue Sep 09 15:59:16 2008 +0200 @@ -35,13 +35,13 @@ import dwt.dwthelper.Runnable; import tango.util.Convert; -import tango.core.Thread; +import dwtx.dwtxhelper.JThread; public final class BusyIndicator : Canvas { alias Canvas.computeSize computeSize; - class BusyThread : Thread { + class BusyThread : JThread { Rectangle bounds; Display display; GC offScreenImageGC; @@ -56,7 +56,7 @@ this.offScreenImage = offScreenImage; } - public void run() { + public override void run() { try { /* * Create an off-screen image to draw on, and fill it with @@ -125,7 +125,7 @@ * Sleep for the specified delay time */ try { - Thread.sleep(MILLISECONDS_OF_DELAY/1000.0); + JThread.sleep(MILLISECONDS_OF_DELAY); } catch (InterruptedException e) { ExceptionPrintStackTrace(e); } @@ -221,8 +221,8 @@ Image offScreenImage = new Image(display, bounds.width, bounds.height); GC offScreenImageGC = new GC(offScreenImage); busyThread = new BusyThread(bounds, display, offScreenImageGC, offScreenImage); - busyThread.priority((Thread.PRIORITY_MIN + Thread.PRIORITY_MAX )/2 + 2); - busyThread.isDaemon(true); + busyThread.setPriority(JThread.NORM_PRIORITY + 2); + busyThread.setDaemon(true); busyThread.start(); }