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

C++ wrapper for Python asyncio.Handle class. More...

#include <PyEventLoop.hh>

Public Types

using id_t = uint32_t
 

Public Member Functions

 AsyncHandle (PyObject *handle)
 
 AsyncHandle (const AsyncHandle &old)=delete
 
 AsyncHandle (AsyncHandle &&old)
 
 ~AsyncHandle ()
 
void cancel ()
 Cancel the scheduled event-loop job. If the job has already been canceled or executed, this method has no effect.
 
bool cancelled ()
 
bool _finishedOrCancelled ()
 
PyObject * getHandleObject () const
 Get the underlying asyncio.Handle Python object.
 
PyObject * swap (PyObject *newHandleObject)
 Replace the underlying asyncio.Handle Python object with the provided value.
 
bool hasRef ()
 Getter for if the timer has been ref'ed.
 
void addRef ()
 Ref the timer so that the event-loop won't exit as long as the timer is active.
 
void removeRef ()
 Unref the timer so that the event-loop can exit.
 
void setDebugInfo (PyObject *obj)
 Set the debug info object for WTFPythonMonkey tool.
 
PyObject * getDebugInfo ()
 

Static Public Member Functions

static id_t newEmpty ()
 Create a new AsyncHandle without an associated asyncio.Handle Python object.
 
static id_t getUniqueId (AsyncHandle &&handle)
 Get the unique timeoutID for JS setTimeout/clearTimeout methods.
 
static AsyncHandlefromId (id_t timeoutID)
 
static bool cancelAll ()
 Cancel all pending event-loop jobs.
 
static auto & getAllTimers ()
 Get an iterator for the AsyncHandles of all timers.
 

Protected Attributes

PyObject * _handle
 
std::atomic_bool _refed = false
 
PyObject * _debugInfo = nullptr
 

Detailed Description

C++ wrapper for Python asyncio.Handle class.

See also
https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.Handle

Member Typedef Documentation

◆ id_t

Constructor & Destructor Documentation

◆ AsyncHandle() [1/3]

PyEventLoop::AsyncHandle::AsyncHandle ( PyObject *  handle)
explicit

◆ AsyncHandle() [2/3]

PyEventLoop::AsyncHandle::AsyncHandle ( const AsyncHandle old)
delete

◆ AsyncHandle() [3/3]

PyEventLoop::AsyncHandle::AsyncHandle ( AsyncHandle &&  old)

◆ ~AsyncHandle()

PyEventLoop::AsyncHandle::~AsyncHandle ( )

Member Function Documentation

◆ _finishedOrCancelled()

bool PyEventLoop::AsyncHandle::_finishedOrCancelled ( )
Returns
true if the job function has already been executed or cancelled.

◆ addRef()

void PyEventLoop::AsyncHandle::addRef ( )

Ref the timer so that the event-loop won't exit as long as the timer is active.

◆ cancel()

void PyEventLoop::AsyncHandle::cancel ( )

Cancel the scheduled event-loop job. If the job has already been canceled or executed, this method has no effect.

◆ cancelAll()

bool PyEventLoop::AsyncHandle::cancelAll ( )
static

Cancel all pending event-loop jobs.

Returns
success

◆ cancelled()

bool PyEventLoop::AsyncHandle::cancelled ( )
Returns
true if the job has been cancelled.

◆ fromId()

static AsyncHandle * PyEventLoop::AsyncHandle::fromId ( id_t  timeoutID)
static

◆ getAllTimers()

static auto & PyEventLoop::AsyncHandle::getAllTimers ( )
static

Get an iterator for the AsyncHandles of all timers.

◆ getDebugInfo()

PyObject * PyEventLoop::AsyncHandle::getDebugInfo ( )

◆ getHandleObject()

PyObject * PyEventLoop::AsyncHandle::getHandleObject ( ) const

Get the underlying asyncio.Handle Python object.

◆ getUniqueId()

static id_t PyEventLoop::AsyncHandle::getUniqueId ( AsyncHandle &&  handle)
static

Get the unique timeoutID for JS setTimeout/clearTimeout methods.

See also
https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#return_value

◆ hasRef()

bool PyEventLoop::AsyncHandle::hasRef ( )

Getter for if the timer has been ref'ed.

◆ newEmpty()

static id_t PyEventLoop::AsyncHandle::newEmpty ( )
static

Create a new AsyncHandle without an associated asyncio.Handle Python object.

Returns
the timeoutId

◆ removeRef()

void PyEventLoop::AsyncHandle::removeRef ( )

Unref the timer so that the event-loop can exit.

◆ setDebugInfo()

void PyEventLoop::AsyncHandle::setDebugInfo ( PyObject *  obj)

Set the debug info object for WTFPythonMonkey tool.

◆ swap()

PyObject * PyEventLoop::AsyncHandle::swap ( PyObject *  newHandleObject)

Replace the underlying asyncio.Handle Python object with the provided value.

Returns
the old asyncio.Handle object

Member Data Documentation

◆ _debugInfo

PyObject* PyEventLoop::AsyncHandle::_debugInfo = nullptr
protected

◆ _handle

PyObject* PyEventLoop::AsyncHandle::_handle
protected

◆ _refed

std::atomic_bool PyEventLoop::AsyncHandle::_refed = false
protected

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