Giter Site home page Giter Site logo

async-event-interval's People

Contributors

stevieb9 avatar

Watchers

 avatar  avatar

async-event-interval's Issues

Two events in one script appear to leak a segment

Test script 81-fork_dup_rand_key.t in IPC::Shareable.

use warnings;
use strict;

use Async::Event::Interval;
use Data::Dumper;
use IPC::Shareable;
use Test::More;

BEGIN {
    if (! $ENV{CI_TESTING}) {
        plan skip_all => "Not on a legit CI platform...";
    }
}

warn "Segs Before: " . IPC::Shareable::ipcs() . "\n" if $ENV{PRINT_SEGS};
my $segs_before = IPC::Shareable::ipcs();

{
    tie my %shared_data, 'IPC::Shareable', {
        key     => 'fork rand dup keys',
        create  => 1,
        destroy => 1
    };

    $shared_data{$$}{called}++;

    my $event_one = Async::Event::Interval->new(0, sub {$shared_data{$$}{called}++});
    my $event_two = Async::Event::Interval->new(0, sub {$shared_data{$$}{called}++});

    $event_one->start;
    $event_two->start;

    sleep 1;

    $event_one->stop;
    $event_two->stop;

    my $one_pid = $event_one->pid;
    my $two_pid = $event_two->pid;

    is exists $shared_data{$one_pid}{called}, 1, "Event one got a rand shm key ok";
    is exists $shared_data{$two_pid}{called}, 1, "Adding srand() ensures _shm_key_rand() gives out rand key in fork()";

    (tied %shared_data)->clean_up_all;
}

IPC::Shareable::_end;
Async::Event::Interval::_end;

warn "Segs After: " . IPC::Shareable::ipcs() . "\n" if $ENV{PRINT_SEGS};
my $segs_after = IPC::Shareable::ipcs();

is $segs_after, $segs_before, "2nd event segs were cleaned up ok";

done_testing();

Output:

Segs Before:       81
ok 1 - Event one got a rand shm key ok
ok 2 - Adding srand() ensures _shm_key_rand() gives out rand key in fork()
Segs After:       82
not ok 3 - 2nd event segs were cleaned up ok
#   Failed test '2nd event segs were cleaned up ok'
#   at t/81-fork_dup_rand_keys.t line 53.
#          got: '      82'
#     expected: '      81'
1..3
# Looks like you failed 1 test of 3.

"timeout" option

Add another param in new() that sets a timeout. If the event hasn't done something in X time, end itself

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.