author | Claus Gittinger <cg@exept.de> |
Tue, 25 Jun 2019 14:28:51 +0200 | |
changeset 5050 | 44fa8672d102 |
parent 3788 | fabaae7a8428 |
permissions | -rw-r--r-- |
2629 | 1 |
"{ Package: 'stx:libbasic2' }" |
2 |
||
3494
438ec9e27f84
Cleanup: introduced AbstractBackgroundJob, made all other jobs subclass of it.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2629
diff
changeset
|
3 |
"{ NameSpace: Smalltalk }" |
438ec9e27f84
Cleanup: introduced AbstractBackgroundJob, made all other jobs subclass of it.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2629
diff
changeset
|
4 |
|
438ec9e27f84
Cleanup: introduced AbstractBackgroundJob, made all other jobs subclass of it.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2629
diff
changeset
|
5 |
AbstractBackgroundJob subclass:#BackgroundPeriodicalJob |
2629 | 6 |
instanceVariableNames:'interval' |
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'System-Support' |
|
10 |
! |
|
11 |
||
12 |
!BackgroundPeriodicalJob class methodsFor:'documentation'! |
|
13 |
||
14 |
documentation |
|
15 |
" |
|
16 |
A BackgroundPeriodicalJob is a specialized form |
|
17 |
of a BackgroundJob that performs given job periodically |
|
18 |
i.e., every X milliseconds. |
|
19 |
||
20 |
[author:] |
|
21 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
|
22 |
||
23 |
[instance variables:] |
|
24 |
interval <TimeDuration> how often to perform a job. |
|
25 |
||
26 |
[class variables:] |
|
27 |
||
28 |
[see also:] |
|
29 |
BackgroundJob |
|
30 |
" |
|
31 |
! |
|
32 |
||
33 |
examples |
|
34 |
" |
|
35 |
| job text | |
|
36 |
text := 'Hello world'. |
|
37 |
job := BackgroundPeriodicalJob named: 'example job' on:[ |
|
38 |
Transcript showCR:'One guy said: ', text |
|
39 |
]. |
|
40 |
job interval: 1000. |
|
41 |
job start. |
|
42 |
Delay waitForSeconds: 3. |
|
43 |
text := 'Haya, you should see this text repeating every second....'. |
|
44 |
job restart. |
|
45 |
Delay waitForSeconds: 3. |
|
46 |
job stop. |
|
47 |
||
48 |
" |
|
49 |
! ! |
|
50 |
||
51 |
!BackgroundPeriodicalJob methodsFor:'accessing'! |
|
52 |
||
53 |
interval |
|
54 |
^ interval |
|
55 |
! |
|
56 |
||
57 |
interval:anIntegerOrTimeDuration |
|
58 |
||
59 |
anIntegerOrTimeDuration isInteger ifTrue:[ |
|
60 |
interval := TimeDuration fromMilliseconds: anIntegerOrTimeDuration. |
|
61 |
] ifFalse:[ |
|
62 |
interval := anIntegerOrTimeDuration. |
|
63 |
]. |
|
64 |
||
65 |
"Modified: / 06-09-2011 / 12:00:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
66 |
! ! |
|
67 |
||
68 |
!BackgroundPeriodicalJob methodsFor:'processing'! |
|
69 |
||
70 |
process |
|
71 |
| delay | |
|
72 |
||
73 |
delay := Delay forMilliseconds: interval getMilliseconds. |
|
74 |
[ |
|
75 |
job value. |
|
76 |
delay wait. |
|
3788 | 77 |
] loop. |
2629 | 78 |
|
79 |
"Created: / 06-09-2011 / 12:01:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3506
bf90531e8a26
Added new API to BackgroundJob: allow to pass down a block to evaluate as background job
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3494
diff
changeset
|
80 |
"Modified: / 21-02-2015 / 10:10:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2629 | 81 |
! ! |
82 |
||
83 |
!BackgroundPeriodicalJob class methodsFor:'documentation'! |
|
84 |
||
85 |
version |
|
3788 | 86 |
^ '$Header$' |
2629 | 87 |
! |
88 |
||
89 |
version_CVS |
|
3788 | 90 |
^ '$Header$' |
2629 | 91 |
! ! |
3494
438ec9e27f84
Cleanup: introduced AbstractBackgroundJob, made all other jobs subclass of it.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2629
diff
changeset
|
92 |