[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: distributed objects



Hi

[..]
>But what does "contain" mean? 

«Contain» means objects or locations that where migrated to the place,
of that were created inside (if a method create a new object, for
instance).

(I give a couple examples later).

>
># class p () = 
>    method p s = print_endline s; flush stdout 
>  end;;
>class p (unit) = method p : string -> unit end
># class m (p: p) =
>    val p = p
>    method m w = Join.go w
>    method p_with_object s = p#p s
>    method my_own_p s = print_endline s; flush stdout 
>  end;;
># let  o = new m (new p ());;
>val o : m = <obj>
># o#my_own_p "my own here";
>  o#p_with_object "with object : here"; 
>  o#m (Ns.lookup "dest" (vartype: Join.location metatype));
>  o#my_own_p "my own there";
>  o#p_with_object "with object : there";;
>Warning: VARTYPE replaced by type 
> Join.location metatype
>my own here
>with object : here
>Using multicast
>Multicast aborted (Failure("setsock_join"))
>Querying name server shiva:20001
>with object : there     <--- no migration of the "contained" object
>- : unit = ()
>
>On the other machine, "my own there" is printed...
>

This example does not work because when the object p is created, it is
created at the toplevel (the new is at the toplevel, not inside the
other object).

>
>So the migration seems to only concern the object itself. I then thought
>that the Join.goo would work:
>
># class p () = method p s = print_endline s; flush stdout end;;
>class p (unit) = method p : string -> unit end
># class m (p : p) as self =
>    val p = p
>    method p s = p#p s
>    method m w =
>      Join.go w;     (* first migrate the current object... *)
>      Join.goo (p :> < >)     (* ... then "contained" objects *)
>  end;;
>class m (p) =
>  val p : p
>  method m : Join.location -> unit
>  method p : string -> unit
>end
># let o = new m (new p ()) in
>  o#p "here";
>  o#m (Ns.lookup "dest" (vartype: Join.location metatype));
>  o#p "there";;
>Warning: VARTYPE replaced by type 
> Join.location metatype
>here
>Using multicast
>Multicast aborted (Failure("setsock_join"))
>Querying name server shiva:20001
>there
>- : unit = ()
>
>
>But, as you can see, it doesn't work either :-)

Well, to me, it works well: you migrate to dest, then to the other
object, which is on the initial runtime. So this is why «there» is
printed there. Join.goo means «migrate to this object», so p has not
moved, and o is inside p at the end.

In other words, as concern migration, objects are like locations. You
can create them inside other objects or locations, or migrate them
there. But as location, it is not because you know the name of an
object (as in val p = p) that it will be sent along.

Now for some examples that work:

First, migrating to an object that migrates :

# class p () = 
  method p s = print_endline s; flush stdout
  method m w = Join.goo w
  end ;;
class p (unit) = method m : <  > -> unit method p : string -> unit end
# class m () = method p s = print_endline s; flush stdout
  method m w = Join.go w
  end ;;
class m (unit) =
  method m : Join.location -> unit
  method p : string -> unit
end
# let p = new p () ;;
val p : p = <obj>
# let m = new m () ;;
val m : m = <obj>
# let dest : Join.location = Ns.lookup "dest" vartype ;;
Warning: VARTYPE replaced by type 
 Join.location metatype
Querying name server alan-schm1p:20001
val dest : Join.location = <abstr>
# p#m (m :> < >) ;;
- : unit = ()
# p#p "toto" ;;
toto
- : unit = ()
# m#p "toto" ;;
toto
- : unit = ()
# m#m dest ;;
- : unit = ()
# m#p "toto" ;;
- : unit = () (* toto gets printed on the other runtime *)
# p#p "toto" ;;
- : unit = () (* toto gets printed on the other runtime *)

Now, creating an object inside another object :

# class test () =
  method c () = new p ()
  method m      w = Join.go w
  end ;;
class test (unit) = method c : unit -> p method m : Join.location -> unit end
# let t = new test () ;;
val t : test = <obj>
# let o = t#c () ;;
val o : p = <obj>
# o#p "toto" ;;
toto
- : unit = ()
# t#m dest ;;
- : unit = ()
# o#p "toto" ;;
- : unit = () (* toto gets printed on the other runtime *)

Alan Schmitt

--
The hacker: someone who figured things out and made something cool happen.