|
| Scott schrieb:
> Uwe Klein wrote:
>
> The basic idea is you have an object with its associated methods. The
> proxy object creates a new thread and instantiates the actual object in
> the new thread and creates methods in the current thread that
> thread::send to the actual object.
> ...
There is quite a similar model implemented in xotcl-core package of
OpenACS. The OpenACS community has TIPed about a year ago to base
future versions of OpenACS on xotcl (i.e. make XOTcl as a
pre-requirement in OpenACS installations). xotcl-core provides a class
called THREAD that can be used as following:
::xotcl::THREAD create t1 {
Class Counter -parameter {{value 1}}
Counter instproc ++ {} {my incr value}
Counter c1
} -persistent 1
t1 forward ++ %self do c1 %proc
This creates a thread with the specified thread-specific code, and a
object t1 used as a proxy object. The proxy object has a "do" method
for delegating commands to the thread. The presented example uses a
forwarder to forward calls like "t1 ++" via "t1 do c1 ++" to the
thread, and returns its results. So
t1 ++ ;### returns 2
t1 ++ ;### returns 3
and can be used from each connection thread without any magic.
This technique is used for several packages in OpenACS, such as the
request-monitor or the background delivery or in the streaming chat
implementation. If you are interested in such applications look to the
forums of http://www.openacs.org and/or come to the workshop in Boston
early November (http://www.openacs.org/xowiki/en/Fall_Conference_2006,
esp. day 2)
|
|