No registered users in community xowiki
in last 10 minutes
in last 10 minutes
Re: [Xotcl] XOTcl and Thread
From: Stefan Sobernig <stefan.sobernig_at_wu.ac.at>
Date: Fri, 11 Feb 2011 10:15:43 +0100
>> What would be the proper way to "register" the object myObject (which already exists) in another thread?
>
> No way. You need to ask Gustaf to give you serialisation-code
> that you can use to replicate your object/classes blueprints
> from one thread into others as a matter of thread inits.
I can help out here: In order to serialize an object (in XOTcl, creating
a canonical script from a in-memory snapshot of the given object,
capable of creating an object and its dependencies with all the
shebang), [package require] the serializer package which comes with your
XOTcl distribution:
Class create C -slots {
Attribute a1 -default aaa
} -set x 1
C create c1
package req xotcl::serializer
#
# this provides a new method to all ::xotcl::Object instances, i.e. all
# objects -> serialize():
#
c1 serialize
-> ::C create ::c1 -noinit \
-set a1 aaa
the resulting script can be stored (e.g., in a tsv) and shared between
thread interps. in the target interp, simply [eval] the script.
//stefan
Date: Fri, 11 Feb 2011 10:15:43 +0100
>> What would be the proper way to "register" the object myObject (which already exists) in another thread?
>
> No way. You need to ask Gustaf to give you serialisation-code
> that you can use to replicate your object/classes blueprints
> from one thread into others as a matter of thread inits.
I can help out here: In order to serialize an object (in XOTcl, creating
a canonical script from a in-memory snapshot of the given object,
capable of creating an object and its dependencies with all the
shebang), [package require] the serializer package which comes with your
XOTcl distribution:
Class create C -slots {
Attribute a1 -default aaa
} -set x 1
C create c1
package req xotcl::serializer
#
# this provides a new method to all ::xotcl::Object instances, i.e. all
# objects -> serialize():
#
c1 serialize
-> ::C create ::c1 -noinit \
-set a1 aaa
the resulting script can be stored (e.g., in a tsv) and shared between
thread interps. in the target interp, simply [eval] the script.
//stefan