>>>>> "MNC" == Mitchell N Charity <[EMAIL PROTECTED]> writes:
> one goal for stem is to get more event loops supported. .11 (out SOON i > hope) has a new event loop design that makes it easy to wrap event loops > from various packages like tk, qt, wxwindows, etc. if someone who is > Could you elaborate? > Will it be a stand-alone alternative to Event and POE? no, stem already runs on event loops such as Event.pm and now its own pure perl event loop (which passes tests on winblows). the new stem event loop layer is designed to wrap other event loops so stem can be driven and interact with other event systems such as tk, qt, etc. the new event layer has a generic module Stem::Event.pm that provides the public OO interface to all other stem modules that need events. many actually only use messages and don't make direct calls to the event layer. but any socket, i/o, timer or signal stuff uses the event API. Stem::Event.pm can load and use a event wrapper module that sits on top of some other event loop (think DBI/DBD). here is an example of the Event.pm wrapper for timers and for read events: package Stem::Event::Timer ; sub _init { my( $self ) = @_ ; my $timer_event = Event->timer( 'cb' => [ $self, 'timer_triggered' ], 'hard' => $self->{'hard'}, 'after' => $self->{'delay'}, 'interval' => $self->{'interval'}, ) ; ref $timer_event or return "Event::EventPM: can't make timer event" ; $self->{'timer_event'} = $timer_event ; return $self ; } sub _reset { my( $self ) = @_ ; my $timer_event = $self->{'timer_event'} ; return unless $timer_event ; $timer_event->again() ; } sub _cancel { my( $self ) = @_ ; my $timer_event = delete $self->{'timer_event'} ; $timer_event->cancel() ; return ; } sub _start { my( $self ) = @_ ; $self->{'timer_event'}->start() ; } sub _stop { my( $self ) = @_ ; $self->{'timer_event'}->stop() ; } ############################################################################ package Stem::Event::Read ; sub _init { my( $self ) = @_ ; # create the read event watcher $self->{'read_event'} = Event->io( 'cb' => sub { $self->trigger( 'read' ) }, 'fd' => $self->{'fh'}, 'poll' => 'r', ) ; return $self ; } sub _cancel { my( $self ) = @_ ; my $read_event = delete $self->{'read_event'} ; $read_event->cancel() ; return ; } sub _stop { my( $self ) = @_ ; $self->{'read_event'}->stop() ; } sub _start { my( $self ) = @_ ; $self->{'read_event'}->start() ; } all the _subs are methods called from the generic Stem::Event.pm module. so to wrap another event loop all you need to do is write these subs and call the real subs in the real event loop module (tk, qt, etc.). note that the classes above are the same as in Stem::Event.pm. the event specific module puts its methods in the same class in the generic event module. the generic module also does much of the higher level stuff such as handling timeouts on read/write events. this simplifies the work needed in the specific event module. as you can see it is very simple code for Event.pm. the write event is very similar to the read event. the signal event is much simpler. and there is a plain event which is very simple. it would not be hard to take Stem::Event::EventPM (the event specific module for Event.pm) and rewrite it for tk and others. this is what i am looking for help with. i am not a user of those GUI systems (i did a little hacking in perl/tk a while back) so i don't know their event api's at all. i could learn then for sure and do this wrapping myself but it is not a high priority for me. so if any of you want to extend your favorite gui package and give it the message passing api that stem provides, i am very open to that and i will help all i can. this is a nice way to learn stem and get into hacking it so go for it if you are interested. note that this new event layer is in .11 which i am trying to get released, but i can get you a snapshot if you want. there is a full test suite for the event system and even test stubs for various event loops. they all share a common event test module so there is no coding needed for testing which makes your work even easier. also if someone is into POE, then a wrapper for its event loop would be very cool and allow stem and poe to share modules. there is some more work there to integrate stem messages and POE events and such but that is not too bad IMO. again, it helps to know poe and i can provide the stem expertise. i have studied poe a fair amount but haven't used it yet. finally, stem provides a high level network framework and message passing API. but you can just use the stem event loop modules and create your own event driven program. i feel that stem's event loop API is the cleanest one around and very easy to use. but using that standalone is not using stem's real power. that comes from the cell (object) design and how they communicate via message passing. a cell can communicate with another cell in the same process, in another process on the same machine or another process on another machine and no code needs to be changed anywhere. where cells live and where they send messages are all controlled by configuration files (which effectively instantiate objects or classes with calls to their constructors and register them so they can receive messages. config files can be written in perl data or YAML and any other config format you want as long as there is a parser for it. i added YAML support in no time just by adding a simple entry into the Stem::Util::load_file sub and putting YAML on the first line of the config file. so you XML zealots can use that to config stem if you want (not supported but easy as i said). so to answer again, stem is not a replacement for Event.pm (it can use it though) or POE (it has a different world view and many features POE doesn't have). have fun and let me know if you wanna do any stem hacking. thanx, uri -- Uri Guttman ------ [EMAIL PROTECTED] -------- http://www.stemsystems.com --Perl Consulting, Stem Development, Systems Architecture, Design and Coding- Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org _______________________________________________ Boston-pm mailing list [EMAIL PROTECTED] http://mail.pm.org/mailman/listinfo/boston-pm