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

RE: Invoking method in other thread context

Thread Previous | Thread Next
Shmuel Fomberg
January 9, 2008 14:13
RE: Invoking method in other thread context
Message ID:
>From: Dean Arnold
>Sent: Wednesday, January 09, 2008 12:39 AM

>> I am currently playing with C#. It have a nice feature that one thread
>> call a function in other thread's context. (using the Invoke command, or
>> asynchronic BeginInvoke command)
>> This is useful especially in a GUI program, where one thread is handling
>> GUI, and worker threads need to post status.
>> So how do we do it in Perl?
>> Sending signal and relaying the command somehow?
>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
>$threadA->callme() directly, ie, no closures needed.

I read the document of Thread::Apartment, and it's one impressive module.
However, I didn't quite understood what the 'urgent' methods are, and how
they are different from regular ones?
Also, the Thread::Apartment->new is creating objects inside the thread pool?
It is not clear from the docs. If so, how do I create such object in the
current thread?

Btw, does every access to a shared variable is really catching a global
lock? It's crazy. Why does it do it?

>But the overhead issues still apply.

Every inter-thread operation is expensive. 


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