At the moment I'm using the main window as the event conduit, rather
than wxTheApp.

I started initially using the app, but when I did this I found that
events don't succeed immediately (on Windows)

Instead, they seem to accumulate somewhere in the ether and then all
arrive in one go when the thread exits.

I've actually now got the thread conduit logic abstracted as role that
I can pull into any class (only once though). So while it's currently
being pulled into the main Padre window, I can switch back later
fairly easily.

Another problem I encountered with using Wx::wxTheApp was that it
wasn't giving me the original (Perl) object, but a clone. Since I
stash the entire main window into a has key on the main app, I was
concerned about accidentally cloning half the universe.

I didn't have any equivalent problems when using the main window.

I should note I'm seeing similar cloning problems with the bindings
for Wx::Window::FindWindow (FindObject?) or something like that.

So another shortcut I'd hoped to use had to be skipped in favour of
using ->GetParent chains, which does return the original Perl objects.

I didn't want these issues to slow down the new threading code, so I
just shelved them at the time.

Adam K

On 17 June 2010 10:36, Mattia Barbon <mattia.bar...@libero.it> wrote:
> Steffen Mueller wrote:
>> Hi Adam,
>>
>> not much time to reply. Not much time to get involved soon. Quick reply.
>>
>> Adam Kennedy wrote:
>>> If anyone wants to investigate some kind of custom Wx loader, it might
>>> let us save as much as 5-10meg per thread, which would mean a 15-30meg
>>> memory reduction in Padre overall, and double or triple the thread
>>> spawn time (which might get the threads fast enough to remove the need
>>> to pre-spawn a bunch of threads, removing another third of a second
>>> from the startup time.
>>>
>>> It's a job there if anyone would like it.
>>
>> Once somebody figured out a general idea how to do that, I'm confident
>> Mattia would be willing to accept patches or ideas. He's been remarkably
>> open to my suggestion of splitting out Wx::Event.
>
>   The delay-load branch of wxPerl contains a Wx::Threading module that
> loads the bare minimum required to send an event from a thread to the
> main loop.  Test script below.
>
> Regards,
> Mattia
>
> #!/usr/bin/perl -w
>
> use strict;
> use threads;
> use threads::shared;
> use Wx::Threading;
> # use Wx;
>
> my $TEST_DONE_EVENT : shared;
>
> sub send_thread_event {
>     sleep 3;
>     my $threvent = new Wx::PlThreadEvent( -1, $TEST_DONE_EVENT, 123 );
>     Wx::PostEvent( Wx::wxTheApp, $threvent );
> }
>
> my $thread;
>
> BEGIN {
>     $TEST_DONE_EVENT = Wx::NewEventType;
>     $thread = threads->create( \&send_thread_event );
> }
>
> use Wx;
>
> my $app = Wx::SimpleApp->new;
>
> Wx::Event::EVT_COMMAND( $app, -1, $TEST_DONE_EVENT,
>                         sub { print "Hi there!\n"; sleep 50 } );
>
> $app->MainLoop;
> _______________________________________________
> Padre-dev mailing list
> Padre-dev@perlide.org
> http://mail.perlide.org/mailman/listinfo/padre-dev
>
_______________________________________________
Padre-dev mailing list
Padre-dev@perlide.org
http://mail.perlide.org/mailman/listinfo/padre-dev

Reply via email to