Async-Event-Interval

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

{
   "abstract" : "Scheduled and one-off asynchronous events",
   "author" : [
      "Steve Bertrand <steveb@cpan.org>"
   ],
   "dynamic_config" : 1,
   "generated_by" : "ExtUtils::MakeMaker version 7.64, CPAN::Meta::Converter version 2.150010",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'Scheduled and one-off asynchronous events'
author:
  - 'Steve Bertrand <steveb@cpan.org>'
build_requires:
  Mock::Sub: '0'
  Test::More: '0'
  Test::SharedFork: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.64, CPAN::Meta::Converter version 2.150010'

README.md  view on Meta::CPAN

# NAME

Async::Event::Interval - Scheduled and one-off asynchronous events

<div>

    <a href="https://github.com/stevieb9/async-event-interval/actions"><img src="https://github.com/stevieb9/async-event-interval/workflows/CI/badge.svg"/></a>
    <a href='https://coveralls.io/github/stevieb9/async-event-interval?branch=master'><img src='https://coveralls.io/repos/stevieb9/async-event-interval/badge.svg?branch=master&service=github' alt='Coverage Status' /></a>
</div>

# SYNOPSIS

A simple event that updates JSON data from a website using a shared scalar

README.md  view on Meta::CPAN


        $event->restart if $event->error;
    }

    sub callback {
        $$json = ...; # Fetch JSON from website
    }

# DESCRIPTION

Very basic implementation of asynchronous events triggered by a timed interval.
If a time of zero is specified, we'll run the event only once.

# METHODS - EVENT OPERATION

## new($delay, $callback, @params)

Returns a new `Async::Event::Interval` object. Does not create the event. Use
`start` for that.

Parameters:

lib/Async/Event/Interval.pm  view on Meta::CPAN

    _end();
}
sub _vim{}

1;

__END__

=head1 NAME

Async::Event::Interval - Scheduled and one-off asynchronous events

=for html
<a href="https://github.com/stevieb9/async-event-interval/actions"><img src="https://github.com/stevieb9/async-event-interval/workflows/CI/badge.svg"/></a>
<a href='https://coveralls.io/github/stevieb9/async-event-interval?branch=master'><img src='https://coveralls.io/repos/stevieb9/async-event-interval/badge.svg?branch=master&service=github' alt='Coverage Status' /></a>


=head1 SYNOPSIS

A simple event that updates JSON data from a website using a shared scalar
variable, while allowing the main application to continue running in the

lib/Async/Event/Interval.pm  view on Meta::CPAN


        $event->restart if $event->error;
    }

    sub callback {
        $$json = ...; # Fetch JSON from website
    }

=head1 DESCRIPTION

Very basic implementation of asynchronous events triggered by a timed interval.
If a time of zero is specified, we'll run the event only once.

=head1 METHODS - EVENT OPERATION

=head2 new($delay, $callback, @params)

Returns a new C<Async::Event::Interval> object. Does not create the event. Use
C<start> for that.

Parameters:

t/05-base.t  view on Meta::CPAN

use Async::Event::Interval;

my $mod = 'Async::Event::Interval';

my $file = 't/test.data';

my $e = $mod->new(0.2, \&perform, 10);

$e->start;

is -e $file, undef, "event is asynchronious";

sleep 2;

$e->stop;

my $data;

{
    local $/;
    open my $fh, '<', $file or die $!;

t/20-restart.t  view on Meta::CPAN

use Async::Event::Interval;

my $mod = 'Async::Event::Interval';

my $file = 't/test.data';

my $e = $mod->new(0.2, \&perform, 10);

$e->restart;

is -e $file, undef, "event is asynchronious";

sleep 2;

$e->stop;

my $data;
{
    local $/;
    open my $fh, '<', $file or die $!;
    $data = <$fh>;



( run in 0.332 second using v1.01-cache-2.11-cpan-0d8aa00de5b )