blob: 0df5832539e85f58b855f85dcdecb7b9a2c20e82 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
TimerScheduler extend [
TimerScheduler class >> initialize [
<category: 'loading'>
"Pharo requires us to do some post-processing"
Smalltalk addToStartUpList: self.
Smalltalk addToShutDownList: self.
^self instance.
]
TimerScheduler class >> startUp [
Smalltalk at: #OsmoTimeScheduler ifPresent: [:timer | timer doStartUp].
]
TimerScheduler class >> shutDown: quitting [
Smalltalk at: #OsmoTimeScheduler ifPresent: [:timer | timer doShutDown].
]
doShutDown [
<category: 'PharoHacks'>
loop ifNil: [^self].
quit := true.
sem critical: [
loopSem ifNotNil: [loopSem signal]].
delay ifNotNil: [:the_delay | the_delay signalWaitingProcess].
processExited wait.
Transcript
nextPutAll: 'Stopped the TimerScheduler process';
cr
]
doStartUp [
<category: 'PharoHacks'>
loop ifNotNil: [^self error: 'The loop should have vanished'].
Transcript nextPutAll: 'Starting the TimerScheduler loop again'; cr.
quit := false.
self startLoop.
]
signalDelay [
"Called with sem critical being consumed"
delay ifNotNil: [delay signalWaitingProcess].
]
scheduleInSeconds: aNumber block: aBlock [
<category: 'schedule'>
^self scheduleIn: aNumber seconds block: aBlock
]
]
Dispatcher class extend [
initialize [
self instance
]
]
|