[CSOD] rSq (was: rST in 3.6?)

David T. Lewis lewis at mail.msen.com
Sat Mar 13 03:53:47 UTC 2004


On Tue, Mar 09, 2004 at 09:57:28AM +0100, Vaidas Didzbalis wrote:
> Hello,
> Package rST does not work in 3.6 image. Will it be maintained in? If 
> not, maybe you could suggest another thing to use in my case.
> System needs to connect to oracle database and perform query with time 
> out option. If time out occurs, execution must be canceled and 
> connection terminated. System must allow multiple queries to run 
> concurrently.
> Maybe this is bad idea, but it is possibility to run multiple images at 
> the same time. Image-Master will give a birth for each Image-Child, ask 
> it to perform a query and get results form child image. Using Major 
> shrink 3.6, I got image 1.75 MB with ODBC in it, quite small

> Vaidas
 
If you are running Squeak on Unix/Linux, perhaps this will help. This
little change set will let you evaluate an expression in a separate
headless Squeak image and return the result to your local squeak image,
without blocking your local Squeak image.

The remote image answers the result using a SmartReferenceStream
communicating through an OSPipe. Requires OSProcess and a Unix VM.

Example:
 OSProcess rSq: [2 + 2] => 4

Dave

-------------- next part --------------
'From Squeak3.7alpha of ''11 September 2003'' [latest update: #5657] on 12 March 2004 at 10:56:24 pm'!
"Change Set:		OSProcess-rSq-dtl
Date:			12 March 2004
Author:			David T. Lewis

Evaluate a block in a remote Squeak image and answer the result
(an object) in the local image.

This currently works on Unix where the remote Squeak image is
forked as a process connected by an OSPipe. The remote image runs
headless and incurs minimal startup delay, as it is forked from an
existing Squeak process. ReferenceStreams are used to communicate
the result of the remote evaluation back to the local Squeak.

Requires OSProcess and a Unix VM.

Example:
 OSProcess rSq: [2 + 2] => 4
"!


!AttachableFileStream methodsFor: 'read, write, position' stamp: 'dtl 3/12/2004 22:32'!
position
	"An error will be produced if seeking on a pipe or other non-positionable
	stream. In this case, the position should be reported as zero."

	[^ super position]
		on: Error
		do: [^ 0]! !


!OSProcess class met!
 hodsFor: 'utility' stamp: 'dtl 3/12/2004 22:45'!
rSq: aBlock
	"Evaluate aBlock in a separate Squeak image, and answer the result of the
	evaluation. The evaluation occurs in the object memory space of the remote
	Squeak image, and has no effect on this Squeak image."

	"OSProcess rSq: [#(1 2 3 4 5) sum]"

	| osPipe child d result |
	d _ Delay forMilliseconds: 100.
	osPipe _ OSPipe new.
	child _ self thisOSProcess forkHeadlessSqueakAndDoThenQuit:
		[(ReferenceStream on: osPipe writer) nextPut: aBlock value; close].
	[child isComplete] whileFalse: [d wait].
	osPipe closeWriter.
	result _ (ReferenceStream on: osPipe reader) next.
	osPipe close.
	^ result
! !


More information about the Squeak-dev mailing list