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