PythonMonkey   v0.8.2 (dev)
Loading...
Searching...
No Matches
PyEventLoop Struct Reference

#include <PyEventLoop.hh>

Collaboration diagram for PyEventLoop:
[legend]

Classes

struct  AsyncHandle
 C++ wrapper for Python asyncio.Handle class. More...
 
struct  Future
 C++ wrapper for Python asyncio.Future class. More...
 
struct  Lock
 

Public Member Functions

 ~PyEventLoop ()
 
bool initialized () const
 
AsyncHandle enqueue (PyObject *jobFn)
 Send job to the Python event-loop.
 
AsyncHandle::id_t enqueueWithDelay (PyObject *jobFn, double delaySeconds, bool repeat)
 Schedule a job to the Python event-loop, with the given delay.
 
Future createFuture ()
 Create a Python asyncio.Future object attached to this Python event-loop.
 
Future ensureFuture (PyObject *awaitable)
 Convert a Python awaitable to asyncio.Future attached to this Python event-loop.
 

Static Public Member Functions

static PyEventLoop getRunningLoop ()
 Get the running Python event-loop on the current thread, or raise a Python RuntimeError if no event-loop running.
 
static PyEventLoop getMainLoop ()
 Get the running Python event-loop on main thread, or raise a Python RuntimeError if no event-loop running.
 

Public Attributes

PyObject * _loop
 

Static Public Attributes

static PyEventLoop::Lock_locker
 

Protected Member Functions

 PyEventLoop ()=delete
 
 PyEventLoop (PyObject *loop)
 

Constructor & Destructor Documentation

◆ ~PyEventLoop()

PyEventLoop::~PyEventLoop ( )

◆ PyEventLoop() [1/2]

PyEventLoop::PyEventLoop ( )
protecteddelete

◆ PyEventLoop() [2/2]

PyEventLoop::PyEventLoop ( PyObject *  loop)
protected

Member Function Documentation

◆ createFuture()

PyEventLoop::Future PyEventLoop::createFuture ( )

Create a Python asyncio.Future object attached to this Python event-loop.

See also
https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.create_future
Returns
a Future wrapper for the Python asyncio.Future object

◆ enqueue()

PyEventLoop::AsyncHandle PyEventLoop::enqueue ( PyObject *  jobFn)

Send job to the Python event-loop.

Parameters
jobFn- The JS event-loop job converted to a Python function
Returns
a AsyncHandle, the value can be safely ignored

◆ enqueueWithDelay()

PyEventLoop::AsyncHandle::id_t PyEventLoop::enqueueWithDelay ( PyObject *  jobFn,
double  delaySeconds,
bool  repeat 
)

Schedule a job to the Python event-loop, with the given delay.

Parameters
jobFn- The JS event-loop job converted to a Python function
delaySeconds- The job function will be called after the given number of seconds
repeat- If true, the job will be executed repeatedly on a fixed interval
Returns
the timeoutId

◆ ensureFuture()

PyEventLoop::Future PyEventLoop::ensureFuture ( PyObject *  awaitable)

Convert a Python awaitable to asyncio.Future attached to this Python event-loop.

See also
https://docs.python.org/3.9/library/asyncio-future.html#asyncio.ensure_future

◆ getMainLoop()

PyEventLoop PyEventLoop::getMainLoop ( )
static

Get the running Python event-loop on main thread, or raise a Python RuntimeError if no event-loop running.

Returns
an instance of PyEventLoop

◆ getRunningLoop()

PyEventLoop PyEventLoop::getRunningLoop ( )
static

Get the running Python event-loop on the current thread, or raise a Python RuntimeError if no event-loop running.

See also
https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop
Returns
an instance of PyEventLoop

◆ initialized()

bool PyEventLoop::initialized ( ) const

Member Data Documentation

◆ _locker

PyEventLoop::Lock* PyEventLoop::_locker
static

◆ _loop

PyObject* PyEventLoop::_loop

The documentation for this struct was generated from the following files: