comparison dwtx/dwtxhelper/JThread.d @ 176:ed80c5c2b550

rm unneeded sync
author Frank Benoit <benoit@tionex.de>
date Fri, 12 Sep 2008 11:25:56 +0200
parents 9e7e1a8bc813
children 987b95661bb9
comparison
equal deleted inserted replaced
175:9e7e1a8bc813 176:ed80c5c2b550
52 } 52 }
53 53
54 public static JThread currentThread(){ 54 public static JThread currentThread(){
55 auto res = getTls().val(); 55 auto res = getTls().val();
56 if( res is null ){ 56 if( res is null ){
57 synchronized(JThread.classinfo){ 57 // no synchronized needed
58 res = getTls().val(); 58 res = new JThread();
59 if( res is null ){ 59 res.thread = Thread.getThis();
60 res = new JThread(); 60 getTls().val( res );
61 res.thread = Thread.getThis();
62 getTls().val( res );
63 }
64 }
65 } 61 }
62 assert( res );
66 return res; 63 return res;
67 } 64 }
68 public int getPriority() { 65 public int getPriority() {
69 return (thread.priority-Thread.PRIORITY_MIN) * (MAX_PRIORITY-MIN_PRIORITY) / (Thread.PRIORITY_MAX-Thread.PRIORITY_MIN) + MIN_PRIORITY; 66 return (thread.priority-Thread.PRIORITY_MIN) * (MAX_PRIORITY-MIN_PRIORITY) / (Thread.PRIORITY_MAX-Thread.PRIORITY_MIN) + MIN_PRIORITY;
70 } 67 }
119 } 116 }
120 public static void sleep( int time ){ 117 public static void sleep( int time ){
121 Thread.sleep(time/1000.0); 118 Thread.sleep(time/1000.0);
122 } 119 }
123 public Thread nativeThread(){ 120 public Thread nativeThread(){
121 assert(thread);
124 return thread; 122 return thread;
125 } 123 }
126 public override char[] toString(){ 124 public override char[] toString(){
127 return "JThread "~thread.name; 125 return "JThread "~thread.name;
128 } 126 }