Mercurial > projects > dwt-addons
comparison dwtx/dwtxhelper/Timer.d @ 167:862b05e0334a
Add a wrapper for Thread
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 09 Sep 2008 15:59:16 +0200 |
parents | 86617aa6b5dd |
children | 1470d66733fa |
comparison
equal
deleted
inserted
replaced
163:e5dd0081ccba | 167:862b05e0334a |
---|---|
1 module dwtx.dwtxhelper.Timer; | 1 module dwtx.dwtxhelper.Timer; |
2 | 2 |
3 import dwtx.dwtxhelper.TimerTask; | 3 import dwtx.dwtxhelper.TimerTask; |
4 import tango.util.container.CircularList; | 4 import tango.util.container.CircularList; |
5 import tango.core.Thread; | 5 import dwtx.dwtxhelper.JThread; |
6 import tango.core.sync.Mutex; | 6 import tango.core.sync.Mutex; |
7 import tango.core.sync.Condition; | 7 import tango.core.sync.Condition; |
8 import tango.time.Time; | 8 import tango.time.Time; |
9 import tango.time.Clock; | 9 import tango.time.Clock; |
10 | 10 |
11 class Timer { | 11 class Timer { |
12 | 12 |
13 alias CircularList!( TimerTask ) ListType; | 13 alias CircularList!( TimerTask ) ListType; |
14 | 14 |
15 private Thread thread; | 15 private JThread thread; |
16 private ListType schedules; | 16 private ListType schedules; |
17 private Mutex mutex; | 17 private Mutex mutex; |
18 private Condition cond; | 18 private Condition cond; |
19 private bool isCanceled = false; | 19 private bool isCanceled = false; |
20 | 20 |
24 this(bool isDaemon){ | 24 this(bool isDaemon){ |
25 mutex = new Mutex(); | 25 mutex = new Mutex(); |
26 cond = new Condition( mutex ); | 26 cond = new Condition( mutex ); |
27 | 27 |
28 schedules = new ListType(); | 28 schedules = new ListType(); |
29 thread = new Thread( &run ); | 29 thread = new JThread( &run ); |
30 thread.isDaemon = isDaemon; | 30 thread.setDaemon( isDaemon ); |
31 thread.start(); | 31 thread.start(); |
32 } | 32 } |
33 private void run(){ | 33 private void run(){ |
34 | 34 |
35 while( !isCanceled ){ | 35 while( !isCanceled ){ |