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:38
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.

Sorry for the double post...I just realized Thread::Apartment may solve
another part of your issue. It exports proxied method calls between
threads, so assuming thread A is running an instance of class XYZ with
method callme(), and thread B is running an instance of class DEF that
holds a proxy object $threadA to thread A's apartment, then thread B can call
$threadA->callme() directly, ie, no closures needed.

But the overhead issues still apply.

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