How about using blocks instead of CompiledMethod's? Blocks can be evaluated by sending #value. You could make the first argument of the block be the "receiver".
-Lex
"Peter Novak" pno@whitestein.com wrote:
:>>> Bob ;>>>
Workspaces were just an example I used for explaining our problem. I should say that I want to create something like better morphs. We are working on prototypes in Squeak. And prototypes do not have ANY class. Morphs are also prototypes, but we don't like the idea of having separate class for each morph only because it has some scripts. What about having objects like morphs with their scripts connected between each other and really working? And now you come to the same problem, because you need to execute scripts for these prototypes (even we need it concurrently). Therefore we were looking for some clear solution, like using some primitive which will execute such a script. But it seems that we have to use some dirty trick (like that with class like UndefinedObject). The question is only to use the most clean from those dirty tricks ;>. John Maloney (I hope he's the one who implemented Morphs, I am sorry if I am wrong) solved this problem in Morphs with creating class for each morph. We are looking for some better solution. We want to have in our prototype based system as few bindings to Smalltalk class system as it will be possible. That's explanation of our problem.
We used workspaces for explaining our problem, because we wanted to explain the problem as simply as it was possible. It seems now, that we made not very good example of that what we want. Nevermind. It's okay now, I think.
Regards,
Peter.
-----Original Message----- From: Bob Arning arning@charm.net To: squeak@cs.uiuc.edu squeak@cs.uiuc.edu Date: 31. marec 2000 16:52 Subject: Re: [Q] executing SOME compiledMethod (classless)
On Fri, 31 Mar 2000 16:22:42 +0200 "Peter Novak" pno@whitestein.com
wrote:
But imagine concurrent Workspaces where SOMEONE (doesn't matter now who - maybe people working in distributed environment) want to evaluate his own expression in his own workspace. Now You have a problem, because you are
not
able to say whose #DoIt will be executed at the moment.
Peter,
I suspect that this is far from the only problem you will encounter with
multiple users sharing one image like that. Too much stuff is not thread safe. One option for the doIt problem (and you did touch on it) would be for each user to have a private class in which context doIts are evaluated (i.e. evaluate the code in PeterNovaksPrivateClass or BobArningsPrivateClass rather than in UndefinedObject). But, as I said, this may be the least of your problems.
Cheers, Bob
Hi folks !
Recently there's been a discussion that my colleague Peter started, about the possible solution for running a code concurrently without having any class for it. For those, involved in this discussion I send a changeset of a simple solution we us. So far it seems to fit to our requirements. If you want, check it out (there are some tests with interesting results - speed)
viktor
Lex Spoon wrote:
How about using blocks instead of CompiledMethod's? Blocks can be evaluated by sending #value. You could make the first argument of the block be the "receiver".
-Lex
---- Whitestein Information Technology Group, Ltd
'From Squeak2.7 of 5 January 2000 [latest update: #1780] on 4 April 2000 at 10:48:23 am'! Object subclass: #Classless instanceVariableNames: 'code ' classVariableNames: '' poolDictionaries: '' category: 'test'! Classless class instanceVariableNames: ''!
!Classless commentStamp: 'vikiz 4/4/2000 10:47' prior: 0! We show here the solutions (yet another trick without using primitives) that seems to fit our requirements: To concurrnetly run a piece of code that has no class and is binded to a receiver only to provide 'self' accessible. This class contains some basic tests that show two different aproaches; using classes or using BlockContexts. (It's interesting that our aproach in several times faster !!!!) Are there some weak spots o in the method we use ? !
!Classless methodsFor: 'execution' stamp: 'vikiz 4/4/2000 10:10'! execute: aBlock in: aReceiverThing with: anArgumentArray "create unique context for each run. The code can run concurrently in many different contexts"
|newContext| newContext _ aBlock copy. newContext home: (aBlock home copy receiver: aReceiverThing). newContext home sender: thisContext. "to allow returnTop from BlockContext" ^newContext valueWithArguments: anArgumentArray. ! !
!Classless methodsFor: 'testing' stamp: 'vikiz 4/4/2000 10:28'! met: aNum aNum>0 ifTrue: [^aNum]. ^'ahoj' ! !
!Classless class methodsFor: 'testing' stamp: 'vikiz 4/4/2000 10:48'! testUsingBlocks "This way of execution doesn't need creation of any Class for each prototype, providing also concurrent execution of a code (by proto's who share this code)"
| code proto | code _ [:num | num > 0 ifTrue: [^ num]. 'ahoj'].
proto _ self new.
50000 timesRepeat: [proto execute: code in: proto with: #( 3 ) ]! !
!Classless class methodsFor: 'testing' stamp: 'vikiz 4/4/2000 10:38'! testUsingClass "This way of execution of a code reqires each prototype to have it's own Class to allow conurrent execution"
| code proto sel | sel _ self compile: 'met: aNum aNum>0 ifTrue: [^aNum]. ^''ahoj'' '.
code _ self compiledMethodAt: sel.
proto _ self new.
50000 timesRepeat: [proto class addSelector: #Do: withMethod: code. proto perform: #Do: withArguments: #(1 )]! !
!BlockContext methodsFor: 'accessing' stamp: 'vikiz 4/4/2000 10:37'! home: aContext
"Ugly trick" home_ aContext! !
!MethodContext methodsFor: 'accessing' stamp: 'vik 4/1/2000 14:10'! receiver:anObject
receiver_ anObject! !
!MethodContext methodsFor: 'accessing' stamp: 'vik 4/1/2000 15:10'! sender: aContext sender_aContext.! !
squeak-dev@lists.squeakfoundation.org