Dear Michal,
Write to following into a file eg. xowiki/tcl/sample-thread-procs.tcl
::xotcl::THREAD create sample-thread {
#
# The following commands are used to initialize the thread. The
# defined procs, classes and objects are available once the thread
# is running and keep their state. One can use in the initialization
# as well "package require ...." for packages that should be
# available in the thread.
#
Class create Counter -parameter {{value 1}}
Counter instproc ++ {} {my incr value}
Counter c1
Counter c2
} -persistent true
# The commands in the thread can be executed via
#
# sample-thread do /cmd/
#
# where /cmd/ is a Tcl command (with possibly several arguments). The
# following command will execute "c1 ++" in the sample-thread and
# return its result. The thread is started the first time the
# sample-thread is addressed.
#
# set x [sample-thread do c1 ++]
#
# The invocation can be simplified by using e.g. a forwarder:
#
# sample-thread forward ++ %self do c1 ++
#
# With this forwarder defined, one can use e.g.
#
# set y [sample-thread ++]
#
When you restart the server, the first time you issue a command
sample-thread do ...
the thread will be started and initialized with the blueprint and additionally the provided initialization commands. So, the first execution will be somewhat slower. Later invocations to
sample-thread do ...
will simply talk to the thread. So, you should be able to package-require ITcl and the corba IDLs in the initialization block. When you name the thread e.g. corba, you can do then simply
corba do
or define some simplifying forwarder, etc.
One can certainly define as well multiple threads this way as well by providing different names. This approach works as well nicely, if one has e.g. to use a non-thread-safe extension as long only one thread is started.
Hope this helps
-gustaf neumann