AnyEvent::Impl::Cocoa - AnyEvent adaptor for Cocoa::EventLoop


AnyEvent documentation Contained in the AnyEvent distribution.

Index


Code Index:

NAME

Top

AnyEvent::Impl::Cocoa - AnyEvent adaptor for Cocoa::EventLoop

SYNOPSIS

Top

    use AnyEvent;
    use Cocoa::EventLoop;

    # do something

DESCRIPTION

Top

This module provides NSRunLoop support to AnyEvent.

NSRunLoop is an event loop for Cocoa applications, wrapped by Cocoa::EventLoop. By using this module, you can use Cocoa based API in your AnyEvent application, or AnyEvent within Cocoa applications.

BUGS

Top

Right now, Cocoa::EventLoop (and this module) are in an early development phase and has some shortcomings and likely bugs.

For example, there seems to be no way to just handle a single event with Cocoa (is there nothing they can implement properly?), so this module currently wakes up at least ten times a second when waiting for events. Also, events caused by timers might get delayed by up to 0.1 seconds.

AUTHORS

Top

Daisuke Murase <typester@cpan.org>, Marc Lehmann <schmorp@schmorp.de>.

COPYRIGHTS

Top

   Copyright (c) 2009 by KAYAC Inc.
   Copyright (c) 2010 by Marc Lehmann <schmorp@schmorp.de>


AnyEvent documentation Contained in the AnyEvent distribution.
package AnyEvent::Impl::Cocoa;

use AnyEvent (); BEGIN { AnyEvent::common_sense }

use Cocoa::EventLoop;

sub io {
   my ($class, %arg) = @_;
   Cocoa::EventLoop->io (%arg);
}

sub timer {
   my ($class, %arg) = @_;
   Cocoa::EventLoop->timer (%arg);
}

sub loop {
   Cocoa::EventLoop->run;
}

sub one_event {
   # this actually is not one event, but it's unable to handle it correctly at Cocoa 
   Cocoa::EventLoop->run_while (0.1);
}

1;