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

RE: Invoking method in other thread context

Thread Previous | Thread Next
From:
Shmuel Fomberg
Date:
January 9, 2008 14:13
Subject:
RE: Invoking method in other thread context
Message ID:
000001c8530c$c9f3f320$6501a8c0@semuel7
>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
>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?
>
>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.

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. 

Thanks,
Shmuel.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About