exit;
    }
    public function basic_sigusr1_event(EventInterface $event)
    {
        echo sprintf("This is a simple sigusr1 event handler. Ivoked by %s \n", $event->getName());
    }
    public function basic_sigint_event(EventInterface $event)
    {
        echo sprintf("This is a simple sigint event handler. Ivoked by %s \n", $event->getName());
        exit;
    }
}
// Initialize event handler
$eventHandler = new BasicSignalEventHandler();
// Initialize event base
$base = new EventBase();
// Create map of events
$map = array(SIGUSR1 => 'basic_sigusr1_event', SIGINT => 'basic_sigint_event', SIGTERM => 'basic_sigterm_event');
/**
 * Prepare and enable events
 * @var Event $event
 */
foreach ($map as $signal => $name) {
    $event = new Event($base, $name);
    $event->prepare($signal, EV_SIGNAL | EV_PERSIST, array($eventHandler, $name), array($signal))->enable();
}
// Base infinite loop
while (true) {
    // Set loop to non block
    $base->loop(EVLOOP_NONBLOCK);
    // Sleep 3 seconds
    /**
     * Event break the base loop on limit
     *
     * @param EventInterface $event
     */
    public function basic_timed_event_03(EventInterface $event)
    {
        $this->counter++;
        echo sprintf("Loop breaking persistent event call %s. Timeout: %s.\n", $event->getName(), $event->getTimeout());
        if ($this->counter === $this->limit) {
            $event->getBase()->loopBreak();
            echo sprintf("Call limit exceed for event %s. Loop break.\n", $event->getName());
        }
    }
}
// Initialize event handler
$eventHandler = new BasicTimedEventHandler(3);
// Initialize event base
$base = new EventBase();
// Map of events
$map = array('basic_timed_event_01' => array('timeout' => 1800000, 'persist' => false), 'basic_timed_event_02' => array('timeout' => 1300000, 'persist' => true), 'basic_timed_event_03' => array('timeout' => 3000000, 'persist' => true));
/**
 * Prepare and enable events
 * @var EventTimer $event
 */
foreach ($map as $name => $arguments) {
    $event = new EventTimer($base, $name);
    $event->prepare(array($eventHandler, $name), array(), $arguments['persist'])->setTimeout($arguments['timeout'])->enable();
}
// Base loop while breaks
$base->loop();
 /**
  * @depends testBaseLoopBreak
  * @expectedException \PHPUnit_Framework_Error
  */
 public function testBaseLoopExit()
 {
     $base = new EventBase();
     $this->assertInstanceOf('Libevent\\Base\\EventBaseInterface', $base->loopExit());
     $base->free();
     $base->loopExit();
 }