Delay.st
author Stefan Vogel <sv@exept.de>
Mon, 22 Jun 2015 11:33:37 +0200
branchexpecco_2_7_5_branch
changeset 18499 b132ac7c9d6a
parent 16404 ebb89de51a93
child 18120 e3a375d5f6a8
child 18996 d27c313ccf06
permissions -rw-r--r--
GLIBC 2.12 compatibility
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
88
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
     1
"
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 92
diff changeset
     3
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
     4
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
     5
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
     6
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
     8
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
     9
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    10
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    11
"
6423
e43f6e61bfaa #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 3917
diff changeset
    12
"{ Package: 'stx:libbasic' }"
e43f6e61bfaa #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 3917
diff changeset
    13
9
b07612967dfa Initial revision
claus
parents:
diff changeset
    14
Object subclass:#Delay
13802
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
    15
	instanceVariableNames:'millisecondDelta resumptionTime delaySemaphore isInterrupted'
777
452133016f54 commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    16
	classVariableNames:''
452133016f54 commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    17
	poolDictionaries:''
452133016f54 commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    18
	category:'Kernel-Processes'
9
b07612967dfa Initial revision
claus
parents:
diff changeset
    19
!
b07612967dfa Initial revision
claus
parents:
diff changeset
    20
88
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    21
!Delay class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    22
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    23
copyright
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    24
"
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    25
 COPYRIGHT (c) 1993 by Claus Gittinger
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 92
diff changeset
    26
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    27
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    28
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    29
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    31
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    32
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    33
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    34
"
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    35
!
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    36
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    37
documentation
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
    38
"
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    39
    Instances of Delay are used to suspend the execution of a process 
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    40
    (i.e. thread) for some time interval. 
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    41
    Delays can be created either for some time-interval (seconds or milliseconds), 
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    42
    or for delaying until a specific time has reached.
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    43
    Once created, a delay is waited upon with Delay>>wait.
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    44
15552
9a800a2e1e81 class: Delay
Claus Gittinger <cg@exept.de>
parents: 13802
diff changeset
    45
    Notice: due to delays (both within Unix AND within Smalltalk itself,
2556
4e58fce26d69 Fix spelling (resumtion --> resumption).
Stefan Vogel <sv@exept.de>
parents: 2422
diff changeset
    46
    the resumption time will ALWAYS be after the actual delay time.
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    47
    (i.e. a Delay for n-millis will actually suspend for more than n milliseconds)
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    48
15552
9a800a2e1e81 class: Delay
Claus Gittinger <cg@exept.de>
parents: 13802
diff changeset
    49
    Warning: 
9a800a2e1e81 class: Delay
Claus Gittinger <cg@exept.de>
parents: 13802
diff changeset
    50
        currently, the implementation does not support delays longer than
9a800a2e1e81 class: Delay
Claus Gittinger <cg@exept.de>
parents: 13802
diff changeset
    51
        a system specific maximum - future versions may remove this limitation.
9a800a2e1e81 class: Delay
Claus Gittinger <cg@exept.de>
parents: 13802
diff changeset
    52
        For now, do not use delays longer than the value returned by
777
452133016f54 commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    53
        OperatingSystem maximumMillisecondTimeDelta
275
a76029ddaa98 *** empty log message ***
claus
parents: 202
diff changeset
    54
15552
9a800a2e1e81 class: Delay
Claus Gittinger <cg@exept.de>
parents: 13802
diff changeset
    55
    Also notice: the clock resolution of the operating system is usually limited
275
a76029ddaa98 *** empty log message ***
claus
parents: 202
diff changeset
    56
    (1/100, 1/60, 1/50, or even 1/20 of a second). Thus very small delays will
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    57
    delay for at least this minimum time interval. See examples.
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    58
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    59
    [see also:]
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    60
        Semaphore Process ProcessorScheduler
8254
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7590
diff changeset
    61
        Time Timestamp OperatingSystem
1348
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
    62
        (Using delay in ``Working with time, delays and interrupts'': programming/timing.html#DELAY)
1294
e26bbb61f6b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    63
e26bbb61f6b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    64
    [author:]
e26bbb61f6b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
    65
        Claus Gittinger
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    66
"
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    67
!
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    68
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    69
examples 
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    70
"
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    71
    Check your systems resolution with:
778
afbb3ebde874 commentary
Claus Gittinger <cg@exept.de>
parents: 777
diff changeset
    72
    (make certain, that no other timed processes are running in the background when doing this)
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    73
                                                                        [exBegin]
777
452133016f54 commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    74
        |d t1 t2 res|
275
a76029ddaa98 *** empty log message ***
claus
parents: 202
diff changeset
    75
777
452133016f54 commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    76
        Processor activeProcess priority:24.
452133016f54 commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    77
        t1 := Time millisecondClockValue.
452133016f54 commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    78
        d := Delay forMilliseconds:1.
452133016f54 commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    79
        100 timesRepeat:[d wait].
452133016f54 commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    80
        t2 := Time millisecondClockValue.
452133016f54 commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    81
        res := (OperatingSystem millisecondTimeDeltaBetween:t2 and:t1) // 100.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
    82
        Transcript show:'minimum delta is about '; show:res; showCR:' milliseconds'.
777
452133016f54 commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    83
        Processor activeProcess priority:8.
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    84
                                                                        [exEnd]
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    85
1273
f8449f53a6a3 commentary
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    86
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    87
    examples:
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    88
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    89
    delaying for some time-delta:
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    90
    (notice: you cannot use this without time-errors in a loop,
2179
3f633442dc34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2178
diff changeset
    91
     since the errors will accumulate; after 10 runs through the loop,
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    92
     more than 5 seconds have passed)
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    93
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    94
            |d|
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    95
            d := Delay forMilliseconds:500.
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    96
            10 timesRepeat:[d wait]
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
    97
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    98
    prove:
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    99
                                                                    [exBegin]
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   100
            |d t1 t2 deltaT|
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   101
            d := Delay forMilliseconds:500.
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   102
            t1 := Time millisecondClockValue.
2178
e255c5cd6dc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   103
            20 timesRepeat:[
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   104
                d wait
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   105
            ].
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   106
            t2 := Time millisecondClockValue.
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   107
            deltaT := OperatingSystem millisecondTimeDeltaBetween:t2 and:t1.
2178
e255c5cd6dc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   108
            Transcript show:'average delay: '; show:deltaT // 20; showCR:' milliseconds'
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   109
                                                                    [exEnd]
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   110
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   111
    delaying until a specific time is reached:
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   112
    (this can be used to fix the above problem)
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   113
                                                                    [exBegin]
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   114
            |now then t1 t2 deltaT|
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   115
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   116
            t1 := Time millisecondClockValue.
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   117
            now := Time millisecondClockValue.
2178
e255c5cd6dc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   118
            20 timesRepeat:[
e255c5cd6dc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   119
                then := OperatingSystem millisecondTimeAdd:now and:500.
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   120
                (Delay untilMilliseconds:then) wait.
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   121
                now := then
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   122
            ].
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   123
            t2 := Time millisecondClockValue.
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   124
            deltaT := OperatingSystem millisecondTimeDeltaBetween:t2 and:t1.
2178
e255c5cd6dc7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   125
            Transcript show:'average delay: '; show:deltaT // 20; showCR:' milliseconds'
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   126
                                                                    [exEnd]
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   127
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   128
    instead of recreating new delays all over, 
2422
a319ee1bf54b open coded valueUninterruptably
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   129
    you can also reuse it (but that does not make a big difference ;-):
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   130
                                                                    [exBegin]
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   131
            |d now then t1 t2 deltaT|
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   132
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   133
            t1 := Time millisecondClockValue.
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   134
            now := Time millisecondClockValue.
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   135
            d := Delay new.
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   136
            10 timesRepeat:[
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   137
                then := OperatingSystem millisecondTimeAdd:now and:1000.
2556
4e58fce26d69 Fix spelling (resumtion --> resumption).
Stefan Vogel <sv@exept.de>
parents: 2422
diff changeset
   138
                d resumptionTime:then.
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   139
                d wait.
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   140
                now := then
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   141
            ].
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   142
            t2 := Time millisecondClockValue.
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   143
            deltaT := OperatingSystem millisecondTimeDeltaBetween:t2 and:t1.
1422
9a0b792f2953 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   144
            Transcript show:'average delay: '; show:deltaT // 10; showCR:' milliseconds'
1316
248a8cb2ae3b examples
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   145
                                                                    [exEnd]
88
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
   146
"
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
   147
! !
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
   148
9
b07612967dfa Initial revision
claus
parents:
diff changeset
   149
!Delay class methodsFor:'instance creation'!
b07612967dfa Initial revision
claus
parents:
diff changeset
   150
16404
ebb89de51a93 class: Delay
Stefan Vogel <sv@exept.de>
parents: 16351
diff changeset
   151
for:aTimeDuration
ebb89de51a93 class: Delay
Stefan Vogel <sv@exept.de>
parents: 16351
diff changeset
   152
    "return a new Delay object for delaying aNumber seconds"
ebb89de51a93 class: Delay
Stefan Vogel <sv@exept.de>
parents: 16351
diff changeset
   153
ebb89de51a93 class: Delay
Stefan Vogel <sv@exept.de>
parents: 16351
diff changeset
   154
    ^ self new delay:aTimeDuration getMilliseconds.
ebb89de51a93 class: Delay
Stefan Vogel <sv@exept.de>
parents: 16351
diff changeset
   155
ebb89de51a93 class: Delay
Stefan Vogel <sv@exept.de>
parents: 16351
diff changeset
   156
    "
ebb89de51a93 class: Delay
Stefan Vogel <sv@exept.de>
parents: 16351
diff changeset
   157
      Delay for:10 seconds
ebb89de51a93 class: Delay
Stefan Vogel <sv@exept.de>
parents: 16351
diff changeset
   158
    "
ebb89de51a93 class: Delay
Stefan Vogel <sv@exept.de>
parents: 16351
diff changeset
   159
!
ebb89de51a93 class: Delay
Stefan Vogel <sv@exept.de>
parents: 16351
diff changeset
   160
38
454b1b94a48e *** empty log message ***
claus
parents: 25
diff changeset
   161
forMilliseconds:aNumber
454b1b94a48e *** empty log message ***
claus
parents: 25
diff changeset
   162
    "return a new Delay object for delaying aNumber milliseconds"
454b1b94a48e *** empty log message ***
claus
parents: 25
diff changeset
   163
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   164
    ^ self new delay:aNumber
9
b07612967dfa Initial revision
claus
parents:
diff changeset
   165
!
b07612967dfa Initial revision
claus
parents:
diff changeset
   166
38
454b1b94a48e *** empty log message ***
claus
parents: 25
diff changeset
   167
forSeconds:aNumber
454b1b94a48e *** empty log message ***
claus
parents: 25
diff changeset
   168
    "return a new Delay object for delaying aNumber seconds"
454b1b94a48e *** empty log message ***
claus
parents: 25
diff changeset
   169
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   170
    ^ self new delay:(aNumber * 1000) rounded
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   171
!
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   172
8254
73b6109ab982 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7590
diff changeset
   173
until:aTimeStamp
275
a76029ddaa98 *** empty log message ***
claus
parents: 202
diff changeset
   174
    "return a new Delay object, that will delay the active process
15630
9e0f47e44106 class: Delay
Stefan Vogel <sv@exept.de>
parents: 15553
diff changeset
   175
     until the system has reached the time represented by the argument."
275
a76029ddaa98 *** empty log message ***
claus
parents: 202
diff changeset
   176
6934
7f47cfcbe755 oops - until: was wrong (setting seconds instead of millis)
Claus Gittinger <cg@exept.de>
parents: 6423
diff changeset
   177
    |numberOfMilliseconds|
275
a76029ddaa98 *** empty log message ***
claus
parents: 202
diff changeset
   178
16351
901dae758e60 class: Delay
Claus Gittinger <cg@exept.de>
parents: 16288
diff changeset
   179
    "/ numberOfMilliseconds := aTimeStamp getMilliseconds - Timestamp now getMilliseconds.
901dae758e60 class: Delay
Claus Gittinger <cg@exept.de>
parents: 16288
diff changeset
   180
    numberOfMilliseconds := aTimeStamp millisecondDeltaFrom:Timestamp now.
6934
7f47cfcbe755 oops - until: was wrong (setting seconds instead of millis)
Claus Gittinger <cg@exept.de>
parents: 6423
diff changeset
   181
    ^ self new delay:numberOfMilliseconds
695
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   182
!
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   183
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   184
untilMilliseconds:aMillisecondTime
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   185
    "return a new Delay object, that will delay the active process
15630
9e0f47e44106 class: Delay
Stefan Vogel <sv@exept.de>
parents: 15553
diff changeset
   186
     until the systems millisecond time has reached aMillisecondTime."
695
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   187
2556
4e58fce26d69 Fix spelling (resumtion --> resumption).
Stefan Vogel <sv@exept.de>
parents: 2422
diff changeset
   188
    ^ self new resumptionTime:aMillisecondTime
4e58fce26d69 Fix spelling (resumtion --> resumption).
Stefan Vogel <sv@exept.de>
parents: 2422
diff changeset
   189
4e58fce26d69 Fix spelling (resumtion --> resumption).
Stefan Vogel <sv@exept.de>
parents: 2422
diff changeset
   190
    "Modified: 18.4.1997 / 11:57:53 / stefan"
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   191
! !
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   192
1033
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   193
!Delay class methodsFor:'queries'!
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   194
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   195
millisecondClockValue
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   196
    "for ST-80 compatibility"
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   197
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   198
    ^ Time millisecondClockValue
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   199
! !
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   200
873
b899dd803470 added combined create & wait
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   201
!Delay class methodsFor:'waiting'!
b899dd803470 added combined create & wait
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   202
11601
597295c0c3ab +waitFor:
Claus Gittinger <cg@exept.de>
parents: 10790
diff changeset
   203
waitFor:aTimeDuration
597295c0c3ab +waitFor:
Claus Gittinger <cg@exept.de>
parents: 10790
diff changeset
   204
    "wait for the given timeDuration.
597295c0c3ab +waitFor:
Claus Gittinger <cg@exept.de>
parents: 10790
diff changeset
   205
     This is a combined instance creation & wait."
597295c0c3ab +waitFor:
Claus Gittinger <cg@exept.de>
parents: 10790
diff changeset
   206
597295c0c3ab +waitFor:
Claus Gittinger <cg@exept.de>
parents: 10790
diff changeset
   207
    ^ (self forMilliseconds:aTimeDuration getMilliseconds) wait
597295c0c3ab +waitFor:
Claus Gittinger <cg@exept.de>
parents: 10790
diff changeset
   208
597295c0c3ab +waitFor:
Claus Gittinger <cg@exept.de>
parents: 10790
diff changeset
   209
597295c0c3ab +waitFor:
Claus Gittinger <cg@exept.de>
parents: 10790
diff changeset
   210
    "
597295c0c3ab +waitFor:
Claus Gittinger <cg@exept.de>
parents: 10790
diff changeset
   211
     Delay waitFor:(TimeDuration seconds:5).
597295c0c3ab +waitFor:
Claus Gittinger <cg@exept.de>
parents: 10790
diff changeset
   212
    "
597295c0c3ab +waitFor:
Claus Gittinger <cg@exept.de>
parents: 10790
diff changeset
   213
!
597295c0c3ab +waitFor:
Claus Gittinger <cg@exept.de>
parents: 10790
diff changeset
   214
1033
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   215
waitForMilliseconds:aNumber
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   216
    "wait for the given number of milliseconds.
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   217
     This is a combined instance creation & wait."
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   218
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   219
    ^ (self forMilliseconds:aNumber) wait
8585
47c2cef4692d comment
Stefan Vogel <sv@exept.de>
parents: 8566
diff changeset
   220
47c2cef4692d comment
Stefan Vogel <sv@exept.de>
parents: 8566
diff changeset
   221
47c2cef4692d comment
Stefan Vogel <sv@exept.de>
parents: 8566
diff changeset
   222
    "
47c2cef4692d comment
Stefan Vogel <sv@exept.de>
parents: 8566
diff changeset
   223
        |start end|
47c2cef4692d comment
Stefan Vogel <sv@exept.de>
parents: 8566
diff changeset
   224
47c2cef4692d comment
Stefan Vogel <sv@exept.de>
parents: 8566
diff changeset
   225
        start := OperatingSystem getMicrosecondTime.
47c2cef4692d comment
Stefan Vogel <sv@exept.de>
parents: 8566
diff changeset
   226
        Delay waitForMilliseconds:1.
47c2cef4692d comment
Stefan Vogel <sv@exept.de>
parents: 8566
diff changeset
   227
        end := OperatingSystem getMicrosecondTime.
47c2cef4692d comment
Stefan Vogel <sv@exept.de>
parents: 8566
diff changeset
   228
47c2cef4692d comment
Stefan Vogel <sv@exept.de>
parents: 8566
diff changeset
   229
        end - start
47c2cef4692d comment
Stefan Vogel <sv@exept.de>
parents: 8566
diff changeset
   230
    "
1033
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   231
!
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   232
873
b899dd803470 added combined create & wait
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   233
waitForSeconds:aNumber
b899dd803470 added combined create & wait
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   234
    "wait for the given number of seconds.
b899dd803470 added combined create & wait
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   235
     This is a combined instance creation & wait."
b899dd803470 added combined create & wait
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   236
b899dd803470 added combined create & wait
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   237
    ^ (self forSeconds:aNumber) wait
12982
ec2cd6e2d39b added: #waitUntil:
Claus Gittinger <cg@exept.de>
parents: 11898
diff changeset
   238
!
ec2cd6e2d39b added: #waitUntil:
Claus Gittinger <cg@exept.de>
parents: 11898
diff changeset
   239
ec2cd6e2d39b added: #waitUntil:
Claus Gittinger <cg@exept.de>
parents: 11898
diff changeset
   240
waitUntil:aTimestamp
ec2cd6e2d39b added: #waitUntil:
Claus Gittinger <cg@exept.de>
parents: 11898
diff changeset
   241
    "wait until a given time is reached.
ec2cd6e2d39b added: #waitUntil:
Claus Gittinger <cg@exept.de>
parents: 11898
diff changeset
   242
     This is a combined instance creation & wait."
ec2cd6e2d39b added: #waitUntil:
Claus Gittinger <cg@exept.de>
parents: 11898
diff changeset
   243
ec2cd6e2d39b added: #waitUntil:
Claus Gittinger <cg@exept.de>
parents: 11898
diff changeset
   244
    ^ (self until:aTimestamp) wait
ec2cd6e2d39b added: #waitUntil:
Claus Gittinger <cg@exept.de>
parents: 11898
diff changeset
   245
ec2cd6e2d39b added: #waitUntil:
Claus Gittinger <cg@exept.de>
parents: 11898
diff changeset
   246
    "Created: / 29-07-2010 / 13:51:41 / cg"
9
b07612967dfa Initial revision
claus
parents:
diff changeset
   247
! !
b07612967dfa Initial revision
claus
parents:
diff changeset
   248
b07612967dfa Initial revision
claus
parents:
diff changeset
   249
!Delay methodsFor:'accessing'!
b07612967dfa Initial revision
claus
parents:
diff changeset
   250
6934
7f47cfcbe755 oops - until: was wrong (setting seconds instead of millis)
Claus Gittinger <cg@exept.de>
parents: 6423
diff changeset
   251
delay:numberOfMillis
10725
cdf2971ca4a4 comment
Claus Gittinger <cg@exept.de>
parents: 10582
diff changeset
   252
    "set the millisecond delta and create a new semaphore internally to wait upon"
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   253
10790
1d0fe0adf6be validate non-nil delayTime args
sr
parents: 10725
diff changeset
   254
    self assert:(numberOfMillis notNil).
6934
7f47cfcbe755 oops - until: was wrong (setting seconds instead of millis)
Claus Gittinger <cg@exept.de>
parents: 6423
diff changeset
   255
    millisecondDelta := numberOfMillis.
2262
4c4d810f006f semaphore names
Claus Gittinger <cg@exept.de>
parents: 2179
diff changeset
   256
    delaySemaphore := Semaphore new name:'delaySema'.
10582
00d5691a2b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8585
diff changeset
   257
13185
1085e6eeb0ef changed: #delay:
Claus Gittinger <cg@exept.de>
parents: 12982
diff changeset
   258
    "Modified: / 22-12-2010 / 14:18:00 / cg"
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   259
!
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   260
695
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   261
delaySemaphore
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   262
    "return the semaphore used to resume the waiting process"
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   263
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   264
    ^ delaySemaphore
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   265
!
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   266
2556
4e58fce26d69 Fix spelling (resumtion --> resumption).
Stefan Vogel <sv@exept.de>
parents: 2422
diff changeset
   267
resumptionTime:aMillisecondTime
11898
2236f1cd95e1 comments
Claus Gittinger <cg@exept.de>
parents: 11601
diff changeset
   268
    "set the resumption time and create a new semaphore internally to wait upon"
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   269
2556
4e58fce26d69 Fix spelling (resumtion --> resumption).
Stefan Vogel <sv@exept.de>
parents: 2422
diff changeset
   270
    resumptionTime := aMillisecondTime.
2262
4c4d810f006f semaphore names
Claus Gittinger <cg@exept.de>
parents: 2179
diff changeset
   271
    delaySemaphore := Semaphore new name:'delaySema'.
2556
4e58fce26d69 Fix spelling (resumtion --> resumption).
Stefan Vogel <sv@exept.de>
parents: 2422
diff changeset
   272
4e58fce26d69 Fix spelling (resumtion --> resumption).
Stefan Vogel <sv@exept.de>
parents: 2422
diff changeset
   273
    "Created: 18.4.1997 / 11:56:14 / stefan"
10582
00d5691a2b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8585
diff changeset
   274
!
00d5691a2b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8585
diff changeset
   275
00d5691a2b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8585
diff changeset
   276
setDelayDuration:numberOfMillis
00d5691a2b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8585
diff changeset
   277
    "set the millisecond delta"
00d5691a2b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8585
diff changeset
   278
10790
1d0fe0adf6be validate non-nil delayTime args
sr
parents: 10725
diff changeset
   279
    self assert:(numberOfMillis notNil).
10582
00d5691a2b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8585
diff changeset
   280
    millisecondDelta := numberOfMillis.
11898
2236f1cd95e1 comments
Claus Gittinger <cg@exept.de>
parents: 11601
diff changeset
   281
    resumptionTime := nil.
2236f1cd95e1 comments
Claus Gittinger <cg@exept.de>
parents: 11601
diff changeset
   282
!
10582
00d5691a2b72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8585
diff changeset
   283
11898
2236f1cd95e1 comments
Claus Gittinger <cg@exept.de>
parents: 11601
diff changeset
   284
setResumptionTime:aMillisecondTime
2236f1cd95e1 comments
Claus Gittinger <cg@exept.de>
parents: 11601
diff changeset
   285
    "set the resumption time"
2236f1cd95e1 comments
Claus Gittinger <cg@exept.de>
parents: 11601
diff changeset
   286
2236f1cd95e1 comments
Claus Gittinger <cg@exept.de>
parents: 11601
diff changeset
   287
    resumptionTime := aMillisecondTime.
2236f1cd95e1 comments
Claus Gittinger <cg@exept.de>
parents: 11601
diff changeset
   288
    millisecondDelta := nil.
9
b07612967dfa Initial revision
claus
parents:
diff changeset
   289
! !
b07612967dfa Initial revision
claus
parents:
diff changeset
   290
b07612967dfa Initial revision
claus
parents:
diff changeset
   291
!Delay methodsFor:'delaying'!
b07612967dfa Initial revision
claus
parents:
diff changeset
   292
b07612967dfa Initial revision
claus
parents:
diff changeset
   293
wait
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   294
    "suspend the current process until either the relative time delta
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   295
     has passed (if millisecondDelta is non-nil), or the absolute millisecondTime
2556
4e58fce26d69 Fix spelling (resumtion --> resumption).
Stefan Vogel <sv@exept.de>
parents: 2422
diff changeset
   296
     has been reached (if resumptionTime non-nil)."
9
b07612967dfa Initial revision
claus
parents:
diff changeset
   297
13802
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   298
    |wasBlocked currentDelta dueTime now then|
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   299
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   300
    isInterrupted := false.
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   301
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   302
    millisecondDelta notNil ifTrue:[
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   303
        now := OperatingSystem getMillisecondTime.
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   304
        currentDelta := millisecondDelta rounded.
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   305
        currentDelta > 16r0fffffff ifTrue:[
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   306
            "NOTE: the microsecondTime is increasing monotonically,
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   307
                   while millisecondTime is wrapping at 16r1fffffff.
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   308
                   So use the microsecondTime to check when we are finished"
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   309
            dueTime := OperatingSystem getMicrosecondTime + (currentDelta * 1000).
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   310
            currentDelta := 16r0fffffff.
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   311
        ].
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   312
        then := OperatingSystem millisecondTimeAdd:now and:currentDelta .
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   313
    ] ifFalse:[
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   314
        then := resumptionTime.
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   315
    ].
2422
a319ee1bf54b open coded valueUninterruptably
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   316
a319ee1bf54b open coded valueUninterruptably
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   317
    wasBlocked := OperatingSystem blockInterrupts.
1033
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   318
    [
13802
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   319
        [
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   320
            Processor signal:delaySemaphore atMilliseconds:then.
15553
8e0b933a9d68 class: Delay
Claus Gittinger <cg@exept.de>
parents: 15552
diff changeset
   321
            Processor activeProcess setStateTo:#timeWait if:#active.
13802
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   322
            delaySemaphore wait.
16288
c599c7f52198 class: Delay
Stefan Vogel <sv@exept.de>
parents: 15630
diff changeset
   323
c599c7f52198 class: Delay
Stefan Vogel <sv@exept.de>
parents: 15630
diff changeset
   324
            dueTime notNil
13802
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   325
              and:[isInterrupted not
16288
c599c7f52198 class: Delay
Stefan Vogel <sv@exept.de>
parents: 15630
diff changeset
   326
              and:[(currentDelta := dueTime - OperatingSystem getMicrosecondTime) > 0
c599c7f52198 class: Delay
Stefan Vogel <sv@exept.de>
parents: 15630
diff changeset
   327
              and:[
13802
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   328
                currentDelta := (currentDelta // 1000) min:16r0fffffff.
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   329
                now := OperatingSystem getMillisecondTime.
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   330
                then := OperatingSystem millisecondTimeAdd:now and:currentDelta.
16288
c599c7f52198 class: Delay
Stefan Vogel <sv@exept.de>
parents: 15630
diff changeset
   331
                true.]]]
c599c7f52198 class: Delay
Stefan Vogel <sv@exept.de>
parents: 15630
diff changeset
   332
        ] whileTrue.
6423
e43f6e61bfaa #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 3917
diff changeset
   333
    ] ensure:[
2422
a319ee1bf54b open coded valueUninterruptably
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   334
        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
a319ee1bf54b open coded valueUninterruptably
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   335
    ]
9
b07612967dfa Initial revision
claus
parents:
diff changeset
   336
88
81dacba7a63a *** empty log message ***
claus
parents: 38
diff changeset
   337
    "
8566
a8101fa70c6c comment
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   338
     Transcript showCR:'1'.
9
b07612967dfa Initial revision
claus
parents:
diff changeset
   339
     (Delay forSeconds:10) wait.
8566
a8101fa70c6c comment
Stefan Vogel <sv@exept.de>
parents: 8254
diff changeset
   340
     Transcript showCR:'2'.
9
b07612967dfa Initial revision
claus
parents:
diff changeset
   341
    "
1033
244530001e84 care to reenable interrupts
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   342
2422
a319ee1bf54b open coded valueUninterruptably
Claus Gittinger <cg@exept.de>
parents: 2262
diff changeset
   343
    "Modified: 26.2.1997 / 15:21:35 / cg"
2556
4e58fce26d69 Fix spelling (resumtion --> resumption).
Stefan Vogel <sv@exept.de>
parents: 2422
diff changeset
   344
    "Modified: 18.4.1997 / 11:56:46 / stefan"
9
b07612967dfa Initial revision
claus
parents:
diff changeset
   345
! !
695
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   346
7425
de40123f867c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7424
diff changeset
   347
!Delay methodsFor:'early signalling'!
de40123f867c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7424
diff changeset
   348
de40123f867c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7424
diff changeset
   349
resume
de40123f867c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7424
diff changeset
   350
    "resume the waiter, even if the delay-time has not yet passed."
de40123f867c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7424
diff changeset
   351
de40123f867c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7424
diff changeset
   352
    [
13802
ae3635b4508e class definition
Stefan Vogel <sv@exept.de>
parents: 13185
diff changeset
   353
        isInterrupted := true.
7425
de40123f867c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7424
diff changeset
   354
        self disable.
de40123f867c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7424
diff changeset
   355
        delaySemaphore signalOnce.
de40123f867c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7424
diff changeset
   356
    ] valueUninterruptably
de40123f867c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7424
diff changeset
   357
de40123f867c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7424
diff changeset
   358
    "Modified: / 9.11.1998 / 20:56:43 / cg"
de40123f867c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7424
diff changeset
   359
! !
7424
d68d1ccc2135 refactored for compatibility
Claus Gittinger <cg@exept.de>
parents: 6934
diff changeset
   360
d68d1ccc2135 refactored for compatibility
Claus Gittinger <cg@exept.de>
parents: 6934
diff changeset
   361
!Delay methodsFor:'private'!
695
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   362
7424
d68d1ccc2135 refactored for compatibility
Claus Gittinger <cg@exept.de>
parents: 6934
diff changeset
   363
disable
d68d1ccc2135 refactored for compatibility
Claus Gittinger <cg@exept.de>
parents: 6934
diff changeset
   364
    "tell the ProcessorScheduler to forget about signaling my semaphore."
d68d1ccc2135 refactored for compatibility
Claus Gittinger <cg@exept.de>
parents: 6934
diff changeset
   365
d68d1ccc2135 refactored for compatibility
Claus Gittinger <cg@exept.de>
parents: 6934
diff changeset
   366
    Processor disableSemaphore:delaySemaphore
695
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   367
! !
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   368
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   369
!Delay class methodsFor:'documentation'!
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   370
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   371
version
16404
ebb89de51a93 class: Delay
Stefan Vogel <sv@exept.de>
parents: 16351
diff changeset
   372
    ^ '$Header: /cvs/stx/stx/libbasic/Delay.st,v 1.51 2014-05-07 14:30:39 stefan Exp $'
12982
ec2cd6e2d39b added: #waitUntil:
Claus Gittinger <cg@exept.de>
parents: 11898
diff changeset
   373
!
ec2cd6e2d39b added: #waitUntil:
Claus Gittinger <cg@exept.de>
parents: 11898
diff changeset
   374
ec2cd6e2d39b added: #waitUntil:
Claus Gittinger <cg@exept.de>
parents: 11898
diff changeset
   375
version_CVS
16404
ebb89de51a93 class: Delay
Stefan Vogel <sv@exept.de>
parents: 16351
diff changeset
   376
    ^ '$Header: /cvs/stx/stx/libbasic/Delay.st,v 1.51 2014-05-07 14:30:39 stefan Exp $'
695
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   377
! !
15552
9a800a2e1e81 class: Delay
Claus Gittinger <cg@exept.de>
parents: 13802
diff changeset
   378