And I have a dog named [PoCo]. :p
A few projects I'm either involved in or annoy the people who are:
Contact Info
- Email: <azhrarnlod at users.sourceforge.net>
- AIM/Y!: AzhrarnLOD
- ICQ: 116080581
- MSN: uhlume@hotmail.com
- IRC: (#chatspike - #darkgalaxy - #winbot)@irc.chatspike.net (#perl - #poe - #pound-perl.pm - #trillian)@Efnet->[irc.secsup.uu.net]
Things to Bug Rocco About
Random thoughts that come to me at work where I can't get on IRC, so I remember to ask later. (Or feel free to add answers here whoever you are reading this)
- [Dynamically load event loops] - I have a config file that defines a gui, how do begin blocks figure in? Will I have to use $POE::Kernel::poe_kernel->run(); (or will POE::Kernel->run() work the same)? What if I want to load a gui after poe is running? Like if I start out with console/curses IO, and I hit a switch to launch a gui? Can I just manually give POE::Loop a kick in the pants to hook in somehow? Or would it be easier to runtime "reboot" POE (kill it off, and then call $poe_kernel->run() again to restart it? Maybe manually unload a few modules if necessary. Hopefully I'll figure it out once I get more of my framework done.
- It's too much work to unload one gui for another. Although it's not quite so bad to stop and start poe itself, just need to sweep out its namespace a bit.
- Ok, I figured this would be easier to just show the code (If you want more, lemme know). Basically, the below subs are part of a larger module, that let me dynamically add an undefined number of logfiles to tail and return input. But, I keep getting garbage collected almost immediatly, and the only way I seem to be able to stop it is by bumping my refcount. I even tried storing a reference to the session in my heap, but that didn't seem to work either. Also, I don't quite get what the significance of the second argument to refcount_increment is. The docs just used "thingy". Seeing as the child session inside the FOO::Inputs::Log component stays alive just fine with the FollowTail wheel, is there a "cleaner' (as in I don't have to mess with POE's references and make GC non-automagic) way to make this parent session stay alive so I can post back events? I pondered making this a wheel, but was not quite sure if this would be exactly suited, and I will eventualyl have otehr similiar components that will need to easily pass data both ways (and wheels seem more suited for one way input from what I have seen - Correct me if I misunderstood them though).
# Takes two args, a file to tail, and a reference to $_[HEAP]->{inputs} sub add_input_log { require POE::Component::FOO::Inputs::Log; croak "Invalid number of arguments to add_input_log (filename and input heap needed)." unless $#_ == 1; my $logfile = File::Spec->rel2abs(shift); my $iheap = shift; $iheap->{logs} = {} unless exists $iheap->{logs}; return if exists $iheap->{logs}->{$logfile}; #Do nothing if already tailing $iheap->{logs}->{$logfile} = POE::Component::FOO::Inputs::Log->tail($logfile); #constructor POE::Session->create( inline_states => { _start => \&input_log_init, foo_msg => \&foo_input, _stop => \&log_stop, }, args => [$iheap->{logs}->{$logfile}->ID] , #Get session ID from PoCo::FOO::Inputs::Log # options => { trace => 1, debug => 1 }, ); } sub input_log_init { $_[KERNEL]->refcount_increment($_[SESSION]->ID, 'log') ; #Oogly - don't really want to have to do this $_[KERNEL]->post($_[ARG0] => "report_event" => "foo_msg") ; # Who's your daddy? Child grabs $_[SENDER] from this } sub foo_input { print "Yay! I got Input! YAY!\n" ; #Never gets reached from the child's postings, as this session _stops too soon. } sub log_stop { print "_stop - PoCo::FOO (log input)\n"; #debugging junk }