Android-cuttlefish cvd tool
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
cuttlefish::InterruptListenerHandle Class Reference

#include <interrupt_listener.h>

Public Member Functions

 ~InterruptListenerHandle ()
 
 InterruptListenerHandle (const InterruptListenerHandle &)=delete
 
InterruptListenerHandleoperator= (const InterruptListenerHandle &)=delete
 
 InterruptListenerHandle (InterruptListenerHandle &&other)=delete
 
InterruptListenerHandleoperator= (InterruptListenerHandle &&other)=delete
 

Private Member Functions

 InterruptListenerHandle (size_t listener_index)
 

Private Attributes

const size_t listener_index_
 

Friends

Result< std::unique_ptr< InterruptListenerHandle > > PushInterruptListener (InterruptListener)
 

Constructor & Destructor Documentation

◆ ~InterruptListenerHandle()

cuttlefish::InterruptListenerHandle::~InterruptListenerHandle ( )

◆ InterruptListenerHandle() [1/3]

cuttlefish::InterruptListenerHandle::InterruptListenerHandle ( const InterruptListenerHandle )
delete

◆ InterruptListenerHandle() [2/3]

cuttlefish::InterruptListenerHandle::InterruptListenerHandle ( InterruptListenerHandle &&  other)
delete

◆ InterruptListenerHandle() [3/3]

cuttlefish::InterruptListenerHandle::InterruptListenerHandle ( size_t  listener_index)
inlineprivate

Member Function Documentation

◆ operator=() [1/2]

InterruptListenerHandle & cuttlefish::InterruptListenerHandle::operator= ( const InterruptListenerHandle )
delete

◆ operator=() [2/2]

InterruptListenerHandle & cuttlefish::InterruptListenerHandle::operator= ( InterruptListenerHandle &&  other)
delete

Friends And Related Function Documentation

◆ PushInterruptListener

Result< std::unique_ptr< InterruptListenerHandle > > PushInterruptListener ( InterruptListener  )
friend

Allows reacting to interrupt-like signals (SIGINT, SIGHUP, SIGTERM). A global stack of interrupt listeners is maintained. When an interrupt signal is received the listener at top of the stack is executed. Returns an object that, when destroyed, disables the listener at the top of the stack, re-enabling the previous one. This function is not thread-safe and shouldn't be called from multiple threads, not even with synchronization. The listeners are executed in a background thread, not in the actual interrupt handler. It's ok to run blocking code in that thread, but disabling the listener may wait for the thread to finish executing, so if the code in the listener could wait for the thread that disables it a deadlock may occur. Similarly, disabling the listener from inside the listener will lead to a deadlock. The listener is given the actual signal received, one of SIGINT, SIGHUP or SIGTERM. To disable the listener (pop it from the listener stack) just destroy the returned handle.

Member Data Documentation

◆ listener_index_

const size_t cuttlefish::InterruptListenerHandle::listener_index_
private

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