author | Claus Gittinger <cg@exept.de> |
Wed, 03 Aug 2011 16:46:20 +0200 | |
changeset 2591 | fe84525321f7 |
parent 2589 | 0d6e28eb03de |
child 2601 | 55c6a3887ebf |
permissions | -rw-r--r-- |
2573 | 1 |
" |
2575 | 2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
2587 | 3 |
All Rights Reserved |
2573 | 4 |
|
2575 | 5 |
Permission is hereby granted, free of charge, to any person |
6 |
obtaining a copy of this software and associated documentation |
|
7 |
files (the 'Software'), to deal in the Software without |
|
8 |
restriction, including without limitation the rights to use, |
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10 |
copies of the Software, and to permit persons to whom the |
|
11 |
Software is furnished to do so, subject to the following |
|
12 |
conditions: |
|
13 |
||
14 |
The above copyright notice and this permission notice shall be |
|
15 |
included in all copies or substantial portions of the Software. |
|
16 |
||
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
24 |
OTHER DEALINGS IN THE SOFTWARE. |
|
2573 | 25 |
" |
2587 | 26 |
"{ Package: 'stx:libbasic2' }" |
2573 | 27 |
|
28 |
BackgroundJob subclass:#BackgroundQueueProcessingJob |
|
29 |
instanceVariableNames:'queue queueAccessLock' |
|
30 |
classVariableNames:'' |
|
31 |
poolDictionaries:'' |
|
2591 | 32 |
category:'System-Support' |
2573 | 33 |
! |
34 |
||
35 |
!BackgroundQueueProcessingJob class methodsFor:'documentation'! |
|
36 |
||
37 |
copyright |
|
38 |
" |
|
2575 | 39 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
2587 | 40 |
All Rights Reserved |
2573 | 41 |
|
2575 | 42 |
Permission is hereby granted, free of charge, to any person |
43 |
obtaining a copy of this software and associated documentation |
|
44 |
files (the 'Software'), to deal in the Software without |
|
45 |
restriction, including without limitation the rights to use, |
|
46 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
47 |
copies of the Software, and to permit persons to whom the |
|
48 |
Software is furnished to do so, subject to the following |
|
49 |
conditions: |
|
50 |
||
51 |
The above copyright notice and this permission notice shall be |
|
52 |
included in all copies or substantial portions of the Software. |
|
53 |
||
54 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
55 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
56 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
57 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
58 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
59 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
60 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
61 |
OTHER DEALINGS IN THE SOFTWARE. |
|
2573 | 62 |
" |
63 |
! ! |
|
64 |
||
65 |
!BackgroundQueueProcessingJob methodsFor:'adding & removing'! |
|
66 |
||
67 |
add: object |
|
68 |
"includes: is not synchronized, but should not harm" |
|
69 |
||
70 |
queueAccessLock critical:[ |
|
2589 | 71 |
(queue includes: object) |
72 |
ifFalse:[queue add: object]. |
|
73 |
self start |
|
74 |
]. |
|
2573 | 75 |
|
76 |
"Created: / 28-04-2011 / 20:40:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
77 |
"Modified: / 18-05-2011 / 23:30:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2589 | 78 |
"Modified (format): / 03-08-2011 / 16:43:01 / cg" |
2573 | 79 |
! ! |
80 |
||
81 |
!BackgroundQueueProcessingJob methodsFor:'initialization'! |
|
82 |
||
83 |
initialize |
|
84 |
"Invoked when a new instance is created." |
|
85 |
||
2584
a6cbe910605d
- CodeHighlightingService refactored to use
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2575
diff
changeset
|
86 |
super initialize. |
2573 | 87 |
queue := OrderedCollection new. |
88 |
queueAccessLock := RecursionLock new. |
|
89 |
||
2584
a6cbe910605d
- CodeHighlightingService refactored to use
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2575
diff
changeset
|
90 |
"Modified: / 29-07-2011 / 10:22:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2573 | 91 |
! ! |
92 |
||
93 |
!BackgroundQueueProcessingJob methodsFor:'processing'! |
|
94 |
||
95 |
process |
|
96 |
||
97 |
| item | |
|
98 |
||
99 |
[ |
|
2589 | 100 |
item := nil. |
101 |
queueAccessLock critical:[ |
|
102 |
queue isEmpty ifFalse:[item := queue removeFirst] |
|
103 |
]. |
|
104 |
item isNil ifFalse:[ |
|
105 |
self processItem: item |
|
106 |
]. |
|
107 |
item notNil. |
|
2573 | 108 |
] whileTrue |
109 |
||
110 |
"Created: / 28-04-2011 / 20:36:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
111 |
"Modified: / 18-05-2011 / 23:30:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2589 | 112 |
"Modified (format): / 03-08-2011 / 16:43:21 / cg" |
2573 | 113 |
! |
114 |
||
115 |
processItem: item |
|
116 |
||
117 |
^job value: item |
|
118 |
||
119 |
"Created: / 28-04-2011 / 20:36:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
120 |
! ! |
|
121 |
||
122 |
!BackgroundQueueProcessingJob class methodsFor:'documentation'! |
|
123 |
||
2591 | 124 |
version |
125 |
^ '$Header: /cvs/stx/stx/libbasic2/BackgroundQueueProcessingJob.st,v 1.6 2011-08-03 14:46:20 cg Exp $' |
|
126 |
! |
|
127 |
||
2573 | 128 |
version_CVS |
2591 | 129 |
^ '$Header: /cvs/stx/stx/libbasic2/BackgroundQueueProcessingJob.st,v 1.6 2011-08-03 14:46:20 cg Exp $' |
2573 | 130 |
! |
131 |
||
132 |
version_SVN |
|
133 |
^ '§Id§' |
|
134 |
! ! |