develooper Front page | perl.ithreads | Postings from January 2008

Re: Invoking method in other thread context

Thread Previous | Thread Next
Dean Arnold
January 8, 2008 14:22
Re: Invoking method in other thread context
Message ID:
Shmuel Fomberg wrote:
> Hi All.
> I am currently playing with C#. It have a nice feature that one thread can
> call a function in other thread's context. (using the Invoke command, or the
> asynchronic BeginInvoke command)
> This is useful especially in a GUI program, where one thread is handling the
> GUI, and worker threads need to post status. 
> So how do we do it in Perl?
> Sending signal and relaying the command somehow?
> Thanks,
> Shmuel.

It *may* be possible using inter-thread signalling, tho that might
be a bit clumsy.

Thread::Apartment provides the ability to pass closures (actually, closure proxies)
between threads, so the recving thread can invoke the closure in the sending thread
at some later point. But that requires a complete apartment threaded
environment, and at present Thread::Apartment's interthread calling overhead
is pretty high (lots of locks and threads::shared queueing). Proxied closures
were added in part to address the heavy reliance on closures in Perl/Tk apps, so it
may be relevant to other GUI apps.

One day I hope to finish Thread::Sociable to address the overhead issue...but
my current account of tuits is running at or near zero at present.

Dean Arnold
Presicient Corp.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About