View · Search · Index
No registered users in community xowiki
in last 10 minutes

[Xotcl] XOTcl and Thread

From: Krzysztof Frukacz <>
Date: Thu, 10 Feb 2011 14:27:13 +0100

Hello again,

I am trying to add multi-threaded support for my application. I now face
a problem witch combining XOTCl and Thread. The problem is that
::thread::create creates a new instance of interpreter which has own
variables. I can have variables shared between threads using ::tsv
functions. So here is how it looks:

1. Thread #1 creates object myObject and stores in a shared variable:
::tsv::set array1 key1 [MyClass myObject]

2. Thread #2 gets the shared variable and tries to call a proc defined
for MyClass:
set localVar [::tsv::get array1 key1]
$localVar doSomething

At this point second thread will throw en exception saying:
Unknown command 'myObject'

What would be the proper way to "register" the object myObject (which
already exists) in another thread?