Fwd: Create a new object.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: Create a new object.

Joshua Gargus-2
(forwarded in case anyone else is following this)

Begin forwarded message:

From: "Rob Van Pamel" <[hidden email]>
Date: November 27, 2006 2:55:45 AM PST
To: "'Joshua Gargus'" <[hidden email]>
Subject: RE: [croquet] Create a new object.

Indeed you are right. It happens when I do a mouseover the new created
object. The space is the space that I created 

I get a reference to the space like this 
newspace := TSpace new.
newspace registerGlobal: #mainEntry.
space := newspace.

I created a global variabele which represents that space? Perhaps there it
goes wrong? 

The Stepper i created in a new process with a delay indeed. 

I have added a Fileout in this message from my class. 

I have the following classes Redcube, NavigatorWorld, NavigatorMaster,
Greencube and redcube (the last 2 are not important because it's the same as
a Redcube)

In navigatorworld I initialize the world( TSpace and objects(Redcubes) ,
create the stepper which updates the world.

To create an object, i give it some specific values like a unique
objectName(which comes from the DB). Read out the x,y,z values. and then i
add it to a list. When all the objects are added to the list i create them.
using the addChild method. This is the same for the initialisation or the
update procedure. 

The stepper is a whole class (which you can see in the myCroquet.st) 
I hope this is fine. 

I hope you understand my code. 

Thanx for the quick response!!




-----Oorspronkelijk bericht-----
Van: Joshua Gargus [[hidden email]] 
Verzonden: maandag 27 november 2006 11:25
Aan: Rob Van Pamel
Onderwerp: Re: [croquet] Create a new object.

It seems likely that you're not adding object properly.  How are you  
getting a reference to the space that you want to add to?  Where is  
the stepper running? (on a Croquet object? on a Morphic object? in a  
Process using Delay>>wait?)

I suspect that you're running the stepper from an object "inside the  
island", which is normally fine, but not if you're triggering a non- 
replicated side-effect like reading an object from a database and  
adding it to the space.  Think of it this way:

Succinctly put, the basis of Croquet's replication model is "If you  
have two identical replicas of a world, and they subsequently process  
the identical events in the same order, then the replicas will remain  
identical".  (putting it even more succinctly: "determinism").

 From your rather sketchy description, I can imagine that things  
might go something like this:
- you start off with 2 synced replicas
- every 5 seconds, a stepper (in both replicas) checks if there is  
something new in the database

If this is correct, then you are already in trouble, because you have  
introduced non-determinism.  There is no guarantee that both replicas  
will get the same result from the database lookup.  This is  
especially true if only one of the machines attempts the database  
connection and creates the object in the space (how can the other  
replica possibly know that an object has been created?), but is also  
true if both machines are connecting to the same (perhaps  
distributed) database.

Here's one way that the above scenario might produce symptoms like  
the stack trace you observed...

If you mouse over the newly created object, all replicas of the  
object should be notified so that they can respond appropriately.   
This notification occurs by sending a replicated message via the  
TFarRef to the object.  The mouse-over processing occurs during  
picking, which happens during rendering (i.e. between ticks of the  
island clock).  The pick operation attempts to find the TFarRef  
corresponding to the picked object, but fails because of the way that  
the object was created (i.e. via a non-replicated action on one  
island replica).

Does this guess sound close?  Could you describe the structure of  
your code in a bit more detail?

Cheers,
Josh


On Nov 27, 2006, at 1:47 AM, Rob Van Pamel wrote:

Hello everybody

I sometimes get an error when i try to add an object to the Tspace.
I do this as following.
-----------
  CODE
-----------
temp := Redcube new.
cube translationX:(cube x)asInteger y:(cube y)asInteger z:(cube z) 
asInteger.
space addChild:cube.

Now this works fine. But i am  working with a database which reads  
out data and that data represents the objects that i add to the  
TSpace. I do this every 5 seconds with a stepper, and when i found  
out that an object is in the database but isn't yet in the Tspace i  
add it in the same way i add it before.
It works but sometimes i get an error like this

Error : This object has no name.
But when i try to debug it, i don't see my code anywhere. Not even  
in the Full Stack. It's about TFarref ,TMutexSet and so on ...

Anybody who has had something like this ?

Thanx in advantage
  Rob





myCroquet.st (13K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Create a new object.

Bert Freudenberg
On Nov 28, 2006, at 20:41 , Rob Van Pamel wrote:

> I now have added the folowing lines to my NavigatorMaster.
>
> spaceRef := island future at:#mainEntry.
> islandRef := spaceRef island.
> (This is creating a TFarRef for my island Right?)
>
> What i don't understand is how you connect to this space. I have a  
> Class NavigatorWorld and a Class NavigatorMaster. In  
> NavigatorMaster i've created the Reference for the island. Now i  
> want to access that Reference to add objects(cubes). But how does  
> NavigatorWorld knows that SpaceRef is a Reference to the island  
> from the other Class? I think i am missing something. Or do i have  
> to add my objects in the NavigatorMaster? I'm getting very confused  
> for the moment. Can you maybe explain a little bit how that future  
> sending works?

Did you read the Croquet Programming Guide?

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Create a new object.

Howard Stearns
In reply to this post by Joshua Gargus-2
I haven't been following this thread very closely, but it *feels*  
like the kind of conversation where there's a lot of detail but less  
understanding of the big picture.

What are you really trying to do again?

I mean this in the sense of what result you want, not how you're  
thinking that you want to go about it. See http://catb.org/esr/faqs/ 
smart-questions.html

Most programming should just be "normal", done completely within the  
island, with no future sends, no TFarRefs, and no references to the  
island or any globals.  Occassionaly, when creating a NON-replicated  
user interface, you will want that UI to send a SMALL number of  
future messages to the island.  E.g., from the harness:
   newObject := self activeIsland future new: MyClass.
   self activeSpace future addChild: newObject.
But this is pretty rare. And for the most part, you don't even really  
have to know how the future send works. You can think of it as just,  
"This is the way you have non-replicated code create something 'as  
soon as convenient at some future time' in a replicated island."

[
If you insist on getting into the detail it's not very hard:
   1. You never (should) see a naked pointer for an object from  
outside the island it lives on. You only see a proxy for it.
    2. These proxies (TFarRefs) are pretty dumb. They only understand  
a few messages, including, particularly, #future. As described in the  
programming guide, #future is handled by replicating the next message  
(#new: and #addChild: in my example above) among all the replicants  
of the objects that the proxy is for.

It may or may not also help you to think of each island running in  
it's own thread. (There are actually many processes running.)  The  
#future mechanism is designed to let you not have to worry about that  
-- to make it easier -- but knowing this should help set of warning  
bells in your head if you should find yourself wondering why you  
don't see stuff from other islands in your debugger stack.
]


On Nov 28, 2006, at 1:41 PM, Rob Van Pamel wrote:

> I now have added the folowing lines to my NavigatorMaster.
>
> spaceRef := island future at:#mainEntry.
> islandRef := spaceRef island.
> (This is creating a TFarRef for my island Right?)
>
> What i don't understand is how you connect to this space. I have a  
> Class NavigatorWorld and a Class NavigatorMaster. In  
> NavigatorMaster i've created the Reference for the island. Now i  
> want to access that Reference to add objects(cubes). But how does  
> NavigatorWorld knows that SpaceRef is a Reference to the island  
> from the other Class? I think i am missing something. Or do i have  
> to add my objects in the NavigatorMaster? I'm getting very confused  
> for the moment. Can you maybe explain a little bit how that future  
> sending works?


Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Create a new object.

Howard Stearns
In reply to this post by Joshua Gargus-2
I'm sorry, I'm still not understanding what you're really trying to do.
The description below is still very prescriptive.  I can't imagine
anyone (e.g., my neighbor, or my son's friend) waking up one morning and
saying, "Man, if only I had a program that added an object to an island
from another process! That would be cool! Oh, and it should check a
database at a given interval, too."

In my opinion (just me), I think you might try taking a step back and
try to describe the end-user problem you're trying to solve, as simply
and jargon-free as possible.

Rob Van Pamel wrote:

> What i want to do is add object to my island from another process.
> The big picture is that i have to check a database at a given interval (eg 10sec). I have implemented it with a delay like this
>
> [ running ] whileTrue: [
>         self step.
>         (Delay forMilliseconds: 5000) wait.
> ].
>
> If i don't put this in a new procees (with fork) the whole system comes very slow. But in step I update my island. which means adding object to my island. And this give's me the problem.
> And i really have ridden the Croquet Programming Guide.
> You must know that i'm quiet new to Croquet - Squeak.
> I hope you understand now what the problem is.
>
> Thanks

--
Howard Stearns
University of Wisconsin - Madison
Division of Information Technology
mailto:[hidden email]
jabber:[hidden email]
voice:+1-608-262-3724

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Create a new object.

Bert Freudenberg
In reply to this post by Joshua Gargus-2
Yes, we need more input. From your description you could just run  
that process in your island, but for some reason you seem to not want  
to do that.

- Bert -

On Nov 30, 2006, at 16:27 , Howard Stearns wrote:

> I'm sorry, I'm still not understanding what you're really trying to  
> do. The description below is still very prescriptive.  I can't  
> imagine anyone (e.g., my neighbor, or my son's friend) waking up  
> one morning and saying, "Man, if only I had a program that added an  
> object to an island from another process! That would be cool! Oh,  
> and it should check a database at a given interval, too."
>
> In my opinion (just me), I think you might try taking a step back  
> and try to describe the end-user problem you're trying to solve, as  
> simply and jargon-free as possible.
>
> Rob Van Pamel wrote:
>> What i want to do is add object to my island from another process.  
>> The big picture is that i have to check a database at a given  
>> interval (eg 10sec). I have implemented it with a delay like this  
>> [ running ] whileTrue: [
>>         self step.
>>         (Delay forMilliseconds: 5000) wait.
>> ].
>> If i don't put this in a new procees (with fork) the whole system  
>> comes very slow. But in step I update my island. which means  
>> adding object to my island. And this give's me the problem. And i  
>> really have ridden the Croquet Programming Guide. You must know  
>> that i'm quiet new to Croquet - Squeak. I hope you understand now  
>> what the problem is.
>> Thanks