Re: Invoking method in other thread context

[email protected] (Dean Arnold) Tue, 08 Jan 2008 14:38:39 -0800
Newsgroups perl.ithreads
Message-ID <[email protected]>
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.