Mercurial > projects > dwt-addons
comparison dwtx/dwtxhelper/JThread.d @ 185:987b95661bb9
Added impl for Timer/TimerTask
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 18 Oct 2008 15:02:49 +0200 |
parents | ed80c5c2b550 |
children |
comparison
equal
deleted
inserted
replaced
184:26589d623405 | 185:987b95661bb9 |
---|---|
1 module dwtx.dwtxhelper.JThread; | 1 module dwtx.dwtxhelper.JThread; |
2 | 2 |
3 import tango.core.Thread; | 3 import tango.core.Thread; |
4 import dwt.dwthelper.utils; | 4 import dwt.dwthelper.utils; |
5 import tango.util.log.Trace; | |
5 | 6 |
6 class JThread { | 7 class JThread { |
7 | 8 |
8 private Thread thread; | 9 private Thread thread; |
9 private Runnable runnable; | 10 private Runnable runnable; |
64 } | 65 } |
65 public int getPriority() { | 66 public int getPriority() { |
66 return (thread.priority-Thread.PRIORITY_MIN) * (MAX_PRIORITY-MIN_PRIORITY) / (Thread.PRIORITY_MAX-Thread.PRIORITY_MIN) + MIN_PRIORITY; | 67 return (thread.priority-Thread.PRIORITY_MIN) * (MAX_PRIORITY-MIN_PRIORITY) / (Thread.PRIORITY_MAX-Thread.PRIORITY_MIN) + MIN_PRIORITY; |
67 } | 68 } |
68 public void setPriority( int newPriority ) { | 69 public void setPriority( int newPriority ) { |
69 thread.priority( (newPriority-MIN_PRIORITY) * (Thread.PRIORITY_MAX-Thread.PRIORITY_MIN) / (MAX_PRIORITY-MIN_PRIORITY) +Thread.PRIORITY_MIN ); | 70 // assert( MIN_PRIORITY < MAX_PRIORITY ); |
71 // assert( Thread.PRIORITY_MIN < Thread.PRIORITY_MAX ); | |
72 auto scaledPrio = (newPriority-MIN_PRIORITY) * (Thread.PRIORITY_MAX-Thread.PRIORITY_MIN) / (MAX_PRIORITY-MIN_PRIORITY) +Thread.PRIORITY_MIN; | |
73 Trace.formatln( "JThread.setPriority: scale ({} {} {}) -> ({} {} {})", MIN_PRIORITY, newPriority, MAX_PRIORITY, Thread.PRIORITY_MIN, scaledPrio, Thread.PRIORITY_MAX); | |
74 // thread.priority( scaledPrio ); | |
70 } | 75 } |
71 | 76 |
72 private void internalRun(){ | 77 private void internalRun(){ |
73 getTls().val( this ); | 78 getTls().val( this ); |
74 if( runnable !is null ){ | 79 if( runnable !is null ){ |