[ENH] fix for Sockets and GC
Lex Spoon
lex at cc.gatech.edu
Fri Sep 24 15:25:26 UTC 1999
Oops, I cut and pasted a little too much, and ended up with newTCP
creating UDP sockets. Here's a fixed version.
Lex
'From Squeak 2.5 of August 6, 1999 on 24 September 1999 at 10:19:32 am'!
"Change Set: SocketGC
Date: 24 September 1999
Author: Lex Spoon
If socket creation fails, do a garbage collect and then try again
"!
!BlockContext methodsFor: 'controlling' stamp: 'ls 9/24/1999 09:45'!
repeatWithGCIf: testBlock
| ans |
"run the receiver, and if testBlock returns true, garbage collect and run the receiver again"
ans _ self value.
(testBlock value: ans) ifTrue: [ Smalltalk garbageCollect. ans _ self value ].
^ans! !
!Socket class methodsFor: 'instance creation' stamp: 'ls 9/24/1999 09:45'!
acceptFrom: aSocket
^[ super new acceptFrom: aSocket ]
repeatWithGCIf: [ :sock | sock isValid not ]! !
!Socket class methodsFor: 'instance creation' stamp: 'ls 9/24/1999 10:19'!
newTCP
"Create a socket and initialise it for TCP"
^[ super new initialize: TCPSocketType ]
repeatWithGCIf: [ :socket | socket isValid not ]! !
!Socket class methodsFor: 'instance creation' stamp: 'ls 9/24/1999 09:44'!
newUDP
"Create a socket and initialise it for UDP"
^[ super new initialize: UDPSocketType ]
repeatWithGCIf: [ :socket | socket isValid not ]! !
More information about the Squeak-dev
mailing list
|