Yes, it is correct that it allows the main thread to communicate with the child 
threads via the Window Message Queue (though I am workin on a way to make it 
last beyond the Window's lifespan).

And techinically... no, sending data that way wont work quite yet...
 but that is the general idea in the end.

I plan on moving things to a ThreadsSafe::SendMessage() form in order to allow 
lifespan of the children beyond that of the window message queue, as well as 
provide and *easy* way of transfering the data to that queue.

the format for sending message then would be more along ths lines of:

ThreadsSafe::SendMessage(MESSAGE, WPARAM, LPARAM[, DATA]);

the reference is a scalar/list/hash/storable object, that will be frozen by 
storable and then put on the destination threads's queue, where it will be sent 
over to the callback for that threads, in its original form via thaw.

But I think you get the general idea. :)

Jason P.


-----Original Message-----
From: Jeremy White [mailto:[EMAIL PROTECTED]
Sent: Sat 2/11/2006 5:19 AM
To: Plum, Jason; perl-win32-gui-users@lists.sourceforge.net
Subject: RE: [perl-win32-gui-users] Thread Safe Message Passing
 

>Since I was looking for something slightly different than Rob had
>provided, I managed to make use of his example (TY Rob) and turn it
>around into something more 'famliliar'.

Thanks for posting the code - the more feedback and comments, the better the 
final solution will be:)

>The attached 2 files:
>ThreadSafe.pm
>Threadsafe_1.pl
>
>The module is built around the idea that there *had* to be a way to get
>messages from the windows thread (main aka tid == 0 ) to the child
>threads.

Would this be the correct usage of your module:

#Add this after the window has been created
$win->AddButton(
        -name => 'test',
-text => 'test',
-pos  => [114, 10],
-height => 20,
-onClick => \&butclick,
);

sub butclick {
  for (1..5) {
    $win->SendMessage(WM_PIPE1,M_DATA,['some data',$_]);
    $win->SendMessage(WM_PIPE2,M_DATA,['some data',$_]);
  }
}

When the button is clicked, 5 messages are sent to both spawned threads. Is 
that correct? Would be correct to say that the essence of your package is 
that it allows the main thread to communicate with child threads via the 
windows message queue?

Cheers,

jez.





Reply via email to