comparison base/src/java/lang/Thread.d @ 77:af948d4bbf8c

Impls for core.jobs
author Frank Benoit <benoit@tionex.de>
date Mon, 13 Apr 2009 13:58:00 +0200
parents 1bf55a6eb092
children 8ae65ae167f5
comparison
equal deleted inserted replaced
76:f05e6e8b2f2d 77:af948d4bbf8c
15 } else { // Phobos 15 } else { // Phobos
16 alias core.thread.Thread TThread; 16 alias core.thread.Thread TThread;
17 } 17 }
18 private TThread thread; 18 private TThread thread;
19 private Runnable runnable; 19 private Runnable runnable;
20 20 private bool interrupted_ = false;
21 version(Tango){ 21 version(Tango){
22 private alias tango.core.Thread.ThreadLocal!(Thread) TTLS; 22 private alias tango.core.Thread.ThreadLocal!(Thread) TTLS;
23 private static TTLS tls; 23 private static TTLS tls;
24 } else { // Phobos 24 } else { // Phobos
25 mixin( "static __thread Thread tls;" ); 25 mixin( "static __thread Thread tls;" );
95 } 95 }
96 public void setPriority( int newPriority ) { 96 public void setPriority( int newPriority ) {
97 // assert( MIN_PRIORITY < MAX_PRIORITY ); 97 // assert( MIN_PRIORITY < MAX_PRIORITY );
98 // assert( tango.core.Thread.Thread.PRIORITY_MIN < tango.core.Thread.Thread.PRIORITY_MAX ); 98 // assert( tango.core.Thread.Thread.PRIORITY_MIN < tango.core.Thread.Thread.PRIORITY_MAX );
99 auto scaledPrio = (newPriority-MIN_PRIORITY) * (TThread.PRIORITY_MAX-TThread.PRIORITY_MIN) / (MAX_PRIORITY-MIN_PRIORITY) +TThread.PRIORITY_MIN; 99 auto scaledPrio = (newPriority-MIN_PRIORITY) * (TThread.PRIORITY_MAX-TThread.PRIORITY_MIN) / (MAX_PRIORITY-MIN_PRIORITY) +TThread.PRIORITY_MIN;
100 getDwtLogger().trace( __FILE__, __LINE__, "Thread.setPriority: scale ({} {} {}) -> ({} {} {})", MIN_PRIORITY, newPriority, MAX_PRIORITY, TThread.PRIORITY_MIN, scaledPrio, TThread.PRIORITY_MAX); 100 // getDwtLogger().trace( __FILE__, __LINE__, "Thread.setPriority: scale ({} {} {}) -> ({} {} {})", MIN_PRIORITY, newPriority, MAX_PRIORITY, TThread.PRIORITY_MIN, scaledPrio, TThread.PRIORITY_MAX);
101 // thread.priority( scaledPrio ); 101 // thread.priority( scaledPrio );
102 } 102 }
103 103
104 private void internalRun(){ 104 private void internalRun(){
105 version(Tango){ 105 version(Tango){
138 public String getName(){ 138 public String getName(){
139 return cast(String)thread.name; 139 return cast(String)thread.name;
140 } 140 }
141 141
142 void interrupt() { 142 void interrupt() {
143 interrupted_ = true;
143 implMissing(__FILE__,__LINE__); 144 implMissing(__FILE__,__LINE__);
144 } 145 }
145 146
146 static bool interrupted() { 147 static bool interrupted() {
147 implMissing(__FILE__,__LINE__); 148 auto t = currentThread();
148 return false; 149 synchronized(t){
150 bool res = t.interrupted_;
151 t.interrupted_ = false;
152 return res;
153 }
149 } 154 }
150 155
151 public void run(){ 156 public void run(){
152 // default impl, do nothing 157 // default impl, do nothing
153 } 158 }