Skip to content

Instantly share code, notes, and snippets.

@deppp
deppp / AnyEvent.pm
Created October 10, 2009 00:00
AnyEvent::CondVar 5.201
# see AnyEvent.pm for full source code
our $WAITING;
sub _wait {
$WAITING
and !$_[0]{_ae_sent}
and Carp::croak "AnyEvent::CondVar: recursive blocking wait detected";
local $WAITING = 1;
AnyEvent->one_event while !$_[0]{_ae_sent};
use AnyEvent::CouchDB;
my $couch = couch('http://localhost:5984/');
my $condvar = $couch->all_dbs;
my $data = $condvar->recv;
use common::sense;
use EV;
use AnyEvent;
use AnyEvent::CouchDB;
my $get_all_dbs = sub {
my $couch = couch('http://localhost:5984/');
my $data = $couch->all_dbs->recv;
};
use common::sense;
use EV;
use AnyEvent;
use AnyEvent::Util;
use AnyEvent::CouchDB;
my @_queue = ();
my $_IS_RUNNING = 0;
sub _schedule;
use strict qw(vars subs);
use feature qw(say state switch);
no warnings;
use warnings qw(FATAL closed threads internal debugging pack substr malloc
unopened portable prototype inplace io pipe unpack regexp
deprecated exiting glob digit printf utf8 layer
reserved parenthesis taint closure semicolon);
no warnings qw(exec newline);
#!/usr/bin/perl -w
use common::sense;
# anyevent uses any earlier preloaded event library
# if it can't find any then it uses it's own pure-perl code
use EV;
use AnyEvent;
use AnyEvent::Handle;
use AnyEvent::Socket;
package App;
use Moose;
use Moose::Util::TypeConstraints;
with 'MooseX::Getopt';
use URI;
subtype 'Uri'
=> as 'Object'
package App::Role::Storage;
use MooseX::Role::Parameterized;
use Moose::Util::TypeConstraints;
use Class::MOP;
my %mapping = (
YAML => [qw/Dump Load/],
JSON => [qw/to_json from_json/],
Storable => [qw/freeze thaw/]
);
package App::TypesLibrary;
use URI;
use MooseX::Types -declare => [qw/
Uri
/];
# imports moose types
use MooseX::Types::Moose qw/Str Object/;
# note that syntax differs from the one when
package App::Person;
use Moose;
use MooseX::Storage;
with Storage (format => 'JSON', io => 'File');
has ['firstname', 'lastname'] => ( isa => 'Str' , is => 'rw' );
package main;