SharedCollection.st
author Claus Gittinger <cg@exept.de>
Mon, 18 Mar 2019 10:59:35 +0100
changeset 4878 5d852ae34bc9
parent 4710 6a37e4e17f25
child 4940 d5d7391bc875
permissions -rw-r--r--
#FEATURE by cg class: SftpURI comment/format in: #readStreamDo: changed: #connectThenDo: return the value of the block
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4709
b26d6c21d910 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
     1
"{ Encoding: utf8 }"
b26d6c21d910 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4499
diff changeset
     2
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 2006 by eXept Software AG
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
              All Rights Reserved
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libbasic2' }"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
3860
224a3ad98604 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
    16
"{ NameSpace: Smalltalk }"
224a3ad98604 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
    17
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
Collection subclass:#SharedCollection
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	instanceVariableNames:'accessLock realCollection'
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
    22
	category:'Collections-Support'
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!SharedCollection class methodsFor:'documentation'!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
copyright
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 2006 by eXept Software AG
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
              All Rights Reserved
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
documentation
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    Instances of this class provide synchronized access (of multiple processes) 
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    to a collection.
1636
a3e5703901c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1635
diff changeset
    45
4148
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    46
    Notice: 
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    47
        the message-forwarding is done by catching subclassResponsibility and
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    48
        doesNotUnderstand errors.
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    49
1636
a3e5703901c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1635
diff changeset
    50
    For performance, and for more complex operation-atomicy, more messages might need
4148
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    51
    an explicit handling. 
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    52
    See the implementation of #at: / #at:put: and #size for examples.
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    53
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    54
    [auhor:]
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    55
        Claus Gittinger
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    56
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    57
    [see also:]
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    58
        Semaphore RecursionLock
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    59
        SharedQueue
0cdfbd3b63c0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
    60
        #synchronized: method in Object.
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
examples
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
                                        [exBegin]
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
        |c|
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
        c := SharedCollection for:(OrderedCollection new).
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
        c add:1.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
        c add:2.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
        c add:3.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
        c addAll:#(4 5 6).
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
        c removeFirst.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
        c removeLast.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
        c inspect.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
                                        [exEnd]
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
                                        [exBegin]
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
        |c|
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
        c := SharedCollection for:(Array new:10).
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
        c at:1 put:5.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
        c replaceFrom:2 to:5 with:#(20 30 40 50).
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
        c inspect.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
                                        [exEnd]
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
! !
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
!SharedCollection class methodsFor:'instance creation'!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
for:aCollection
4336
f330feaa0125 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4291
diff changeset
    93
    "create and return a new shareCollection which protects
f330feaa0125 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4291
diff changeset
    94
     access to aCollection.
f330feaa0125 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4291
diff changeset
    95
     I.e. to return a threadSave accessor on it."
f330feaa0125 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4291
diff changeset
    96
     
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    ^ self new initializeFor:aCollection
4336
f330feaa0125 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4291
diff changeset
    98
f330feaa0125 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4291
diff changeset
    99
    "Modified (comment): / 18-02-2017 / 10:49:03 / cg"
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
! !
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
4710
6a37e4e17f25 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4709
diff changeset
   102
!SharedCollection methodsFor:'accessing'!
6a37e4e17f25 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4709
diff changeset
   103
6a37e4e17f25 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4709
diff changeset
   104
synchronizationSemaphore
6a37e4e17f25 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4709
diff changeset
   105
    ^ accessLock
6a37e4e17f25 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4709
diff changeset
   106
! !
6a37e4e17f25 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4709
diff changeset
   107
1634
466927adcd9c +asSharedCollection
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
   108
!SharedCollection methodsFor:'converting'!
466927adcd9c +asSharedCollection
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
   109
466927adcd9c +asSharedCollection
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
   110
asSharedCollection
466927adcd9c +asSharedCollection
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
   111
    ^ self.
466927adcd9c +asSharedCollection
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
   112
! !
466927adcd9c +asSharedCollection
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
   113
3212
5c1eba42b00f class: SharedCollection
Stefan Vogel <sv@exept.de>
parents: 3022
diff changeset
   114
!SharedCollection methodsFor:'copying'!
5c1eba42b00f class: SharedCollection
Stefan Vogel <sv@exept.de>
parents: 3022
diff changeset
   115
5c1eba42b00f class: SharedCollection
Stefan Vogel <sv@exept.de>
parents: 3022
diff changeset
   116
shallowCopy
5c1eba42b00f class: SharedCollection
Stefan Vogel <sv@exept.de>
parents: 3022
diff changeset
   117
    "analog to species - copy the real collection"
5c1eba42b00f class: SharedCollection
Stefan Vogel <sv@exept.de>
parents: 3022
diff changeset
   118
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   119
    ^ accessLock critical:[
3213
53857e1b18a4 class: SharedCollection
Stefan Vogel <sv@exept.de>
parents: 3212
diff changeset
   120
        "get a consistent copy"
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   121
        realCollection shallowCopy
3213
53857e1b18a4 class: SharedCollection
Stefan Vogel <sv@exept.de>
parents: 3212
diff changeset
   122
    ].
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   123
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   124
    "Modified: / 02-02-2017 / 17:03:55 / stefan"
3212
5c1eba42b00f class: SharedCollection
Stefan Vogel <sv@exept.de>
parents: 3022
diff changeset
   125
! !
5c1eba42b00f class: SharedCollection
Stefan Vogel <sv@exept.de>
parents: 3022
diff changeset
   126
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
!SharedCollection methodsFor:'initialization'!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
initializeFor:aCollection
4499
d163f325074d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4355
diff changeset
   130
    accessLock := RecursionLock name:'SharedCollection'.
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    realCollection := aCollection.
4355
9d6595f00a6e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4336
diff changeset
   132
9d6595f00a6e #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4336
diff changeset
   133
    "Modified: / 23-02-2017 / 12:41:45 / stefan"
4499
d163f325074d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4355
diff changeset
   134
    "Modified: / 09-08-2017 / 11:59:29 / cg"
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
! !
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
!SharedCollection methodsFor:'message forwarding'!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
1929
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
   139
add:anElement
2927
b7b7931cb32d comment/format in: #add:
Claus Gittinger <cg@exept.de>
parents: 2515
diff changeset
   140
    "add the argument, anObject to the receiver.
b7b7931cb32d comment/format in: #add:
Claus Gittinger <cg@exept.de>
parents: 2515
diff changeset
   141
     Return the added element."
b7b7931cb32d comment/format in: #add:
Claus Gittinger <cg@exept.de>
parents: 2515
diff changeset
   142
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   143
    ^ accessLock critical:[
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   144
        realCollection add:anElement
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   145
    ].
1929
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
   146
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   147
    "Modified: / 02-02-2017 / 17:01:08 / stefan"
1929
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
   148
!
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
   149
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
at:index
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   151
    ^ accessLock critical:[
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   152
        realCollection at:index
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   153
    ].
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   155
    "Modified: / 02-02-2017 / 17:01:23 / stefan"
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
at:index put:value
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   159
    ^ accessLock critical:[
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   160
        realCollection at:index put:value
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   161
    ].
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   163
    "Modified: / 02-02-2017 / 17:01:35 / stefan"
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   166
do:aBlock
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   167
    ^ accessLock critical:[
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   168
        realCollection do:aBlock
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   169
    ].
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   170
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   171
    "Created: / 22-11-2010 / 21:01:21 / cg"
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   172
    "Modified: / 02-02-2017 / 17:02:00 / stefan"
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   173
!
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   174
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
doesNotUnderstand:aMessage
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    "catches everything not understood by the collection protocol"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   178
    ^ accessLock critical:[
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   179
        aMessage sendTo:realCollection
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
    ].
1794
603885d999ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1637
diff changeset
   181
603885d999ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1637
diff changeset
   182
    "Modified: / 07-12-2006 / 17:38:30 / cg"
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   183
    "Modified: / 02-02-2017 / 17:02:18 / stefan"
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   186
isEmpty
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   187
    ^ accessLock critical:[
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   188
        realCollection isEmpty
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   189
    ].
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   190
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   191
    "Created: / 22-11-2010 / 20:59:01 / cg"
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   192
    "Modified: / 02-02-2017 / 11:40:56 / stefan"
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   193
!
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   194
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   195
notEmpty
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   196
    ^ accessLock critical:[
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   197
        realCollection notEmpty
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   198
    ].
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   199
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   200
    "Created: / 22-11-2010 / 20:59:06 / cg"
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   201
    "Modified: / 02-02-2017 / 17:00:36 / stefan"
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   202
!
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   203
4286
7bd2d76a4f79 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 4148
diff changeset
   204
remove:someElement ifAbsent:aBlock
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   205
    ^ accessLock critical:[
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   206
        realCollection remove:someElement ifAbsent:aBlock
4286
7bd2d76a4f79 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 4148
diff changeset
   207
    ].
7bd2d76a4f79 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 4148
diff changeset
   208
7bd2d76a4f79 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 4148
diff changeset
   209
    "Created: / 25-01-2017 / 22:57:32 / stefan"
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   210
    "Modified: / 02-02-2017 / 17:00:54 / stefan"
4286
7bd2d76a4f79 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 4148
diff changeset
   211
!
7bd2d76a4f79 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 4148
diff changeset
   212
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   213
removeAllSuchThat:aBlock
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   214
    ^ accessLock critical:[
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   215
        realCollection removeAllSuchThat:aBlock
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   216
    ].
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   217
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   218
    "Created: / 22-11-2010 / 20:59:27 / cg"
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   219
    "Modified: / 02-02-2017 / 17:02:38 / stefan"
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   220
!
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   221
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   222
removeIdentical:someElement ifAbsent:aBlock
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   223
    ^ accessLock critical:[
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   224
       realCollection removeIdentical:someElement ifAbsent:aBlock
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   225
    ].
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   226
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   227
    "Created: / 22-11-2010 / 21:00:33 / cg"
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   228
    "Modified: / 02-02-2017 / 17:02:52 / stefan"
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   229
!
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   230
1635
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   231
size
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   232
    ^ accessLock critical:[
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   233
        realCollection size
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   234
    ].
1635
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   235
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   236
    "Modified: / 02-02-2017 / 17:03:06 / stefan"
1635
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   237
!
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   238
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
subclassResponsibility
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
    "catches every required message of the collection protocol"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   242
    |msg|
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    msg := thisContext sender message.
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   245
    ^ accessLock critical:[
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   246
        msg sendTo:realCollection
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    ].
4291
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   248
a67c299b4c60 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4286
diff changeset
   249
    "Modified: / 02-02-2017 / 17:03:25 / stefan"
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
! !
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
3212
5c1eba42b00f class: SharedCollection
Stefan Vogel <sv@exept.de>
parents: 3022
diff changeset
   252
!SharedCollection methodsFor:'queries'!
1637
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   253
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   254
species
3860
224a3ad98604 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   255
    "returns non shared collection's species"
1637
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   256
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   257
    ^ realCollection species
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   258
! !
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   259
3013
28d92a912dfa added isFixedSize query
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
   260
!SharedCollection methodsFor:'testing'!
28d92a912dfa added isFixedSize query
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
   261
28d92a912dfa added isFixedSize query
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
   262
isFixedSize
28d92a912dfa added isFixedSize query
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
   263
    "return true if the receiver cannot grow"
28d92a912dfa added isFixedSize query
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
   264
28d92a912dfa added isFixedSize query
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
   265
    ^ realCollection isFixedSize
28d92a912dfa added isFixedSize query
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
   266
! !
28d92a912dfa added isFixedSize query
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
   267
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
!SharedCollection class methodsFor:'documentation'!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
version
3860
224a3ad98604 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   271
    ^ '$Header$'
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   272
!
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   273
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   274
version_CVS
3860
224a3ad98604 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3213
diff changeset
   275
    ^ '$Header$'
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
! !
2927
b7b7931cb32d comment/format in: #add:
Claus Gittinger <cg@exept.de>
parents: 2515
diff changeset
   277