January 2012 Archives

Call of the callback: Inversion of Control or just coolness?

Suppose I have a Runner which holds a Prober object. I need the Runner to call the Prober and update stuff according to the result. Pretty simple, right?


my $prober = Prober->new(...);
my $result = $prober->check;
if ( $result eq 'whatiwant' ) {
$self->update($stuff);
}

However, I'm running in asynchronous mode, which means I need the prober and update to run somewhere in the loop, and I can't just sit around and wait for a reply. I gotz otha dingz to do, mon! So, I have two options:

- I call th…

I love MooseX::Role::Loggable

I love Log::Dispatchouli. I really do. I does a lot of work so you don't have to, and that's usually the type of stuff rjbs does.

After using Log::Dispatchouli for two projects, I decided to refactor it. No point in having code duplicity, right? So I refactored it into a role and called that role MooseX::Role::Loggable. That code is obviously on CPAN and has been for quite a while.

Once you add MooseX::Role:…

AnyEvent timers shouldn't use type constraints

While I'm rambling about AnyEvent (which I'll probably do more often), here's a note I'd like to give myself.

I'm using AnyEvent in a big app with objects (objects are, generally, good!) and I have a lazy attribute (lazy attributes are good!) of an AnyEvent timer. This is so the timer doesn't lose scope and will be closed.

At first the constraint was a EV::Timer object. On one machine this failed the type constraint while on another it worked. Some of you already know why. Then I changed it to a generic Object. This failed one as well. Why?

Because AnyEvent is basicall…

Learning AnyEvent

When people hear I learned POE much faster than AnyEvent, they're usually surprised. I don't know why, but POE always made a whole lot of sense to me than AnyEvent. I've used POE in several projects (some pretty big) and it was always easy to work with, always had every component I wanted (except the SSH I wanted, though that exists too now) and the community was totally supportive and helpful. This is not unlike AnyEvent, though. I just haven't used it much.

Recently I started using AnyEvent. Not because I don't like POE anymore but because I wanted to be familiar with both. I have t…

About Sawyer X

user-pic Gots to do the bloggingz