GRPC C++  1.66.0
Public Member Functions
grpc::Alarm Class Reference

Trigger a CompletionQueue event, or asynchronous callback execution, after some deadline. More...

#include <alarm.h>

Public Member Functions

 Alarm ()
 Create an unset Alarm. More...
 
 ~Alarm () override
 Destroy the given completion queue alarm, cancelling it in the process. More...
 
template<typename T >
 Alarm (grpc::CompletionQueue *cq, const T &deadline, void *tag)
 DEPRECATED: Create and set a completion queue alarm instance associated to cq. More...
 
template<typename T >
void Set (grpc::CompletionQueue *cq, const T &deadline, void *tag)
 Trigger an alarm instance on completion queue cq at the specified time. More...
 
 Alarm (const Alarm &)=delete
 Alarms aren't copyable. More...
 
Alarmoperator= (const Alarm &)=delete
 
 Alarm (Alarm &&rhs) noexcept
 Alarms are movable. More...
 
Alarmoperator= (Alarm &&rhs) noexcept
 
void Cancel ()
 Cancel a completion queue alarm. More...
 
template<typename T >
void Set (const T &deadline, std::function< void(bool)> f)
 Set an alarm to invoke callback f. More...
 

Detailed Description

Trigger a CompletionQueue event, or asynchronous callback execution, after some deadline.

The Alarm API has separate Set methods for CompletionQueues and callbacks, but only one can be used at any given time. After an alarm has been triggered or cancelled, the same Alarm object may reused.

Alarm methods are not thread-safe. Applications must ensure a strict ordering between calls to Set and Cancel. This also implies that any cancellation that occurs before the alarm has been set will have no effect on any future Set calls.

Constructor & Destructor Documentation

◆ Alarm() [1/4]

grpc::Alarm::Alarm ( )

Create an unset Alarm.

◆ ~Alarm()

grpc::Alarm::~Alarm ( )
override

Destroy the given completion queue alarm, cancelling it in the process.

◆ Alarm() [2/4]

template<typename T >
grpc::Alarm::Alarm ( grpc::CompletionQueue cq,
const T &  deadline,
void *  tag 
)
inline

DEPRECATED: Create and set a completion queue alarm instance associated to cq.

This form is deprecated because it is inherently racy.

◆ Alarm() [3/4]

grpc::Alarm::Alarm ( const Alarm )
delete

Alarms aren't copyable.

◆ Alarm() [4/4]

grpc::Alarm::Alarm ( Alarm &&  rhs)
inlinenoexcept

Alarms are movable.

Member Function Documentation

◆ Cancel()

void grpc::Alarm::Cancel ( )

Cancel a completion queue alarm.

Calling this function over an alarm that has already fired has no effect.

◆ operator=() [1/2]

Alarm& grpc::Alarm::operator= ( Alarm &&  rhs)
inlinenoexcept

◆ operator=() [2/2]

Alarm& grpc::Alarm::operator= ( const Alarm )
delete

◆ Set() [1/2]

template<typename T >
void grpc::Alarm::Set ( const T &  deadline,
std::function< void(bool)>  f 
)
inline

Set an alarm to invoke callback f.

The argument to the callback states whether the alarm expired at deadline (true) or was cancelled (false)

◆ Set() [2/2]

template<typename T >
void grpc::Alarm::Set ( grpc::CompletionQueue cq,
const T &  deadline,
void *  tag 
)
inline

Trigger an alarm instance on completion queue cq at the specified time.

Once the alarm expires (at deadline) or it's cancelled (see Cancel), an event with tag tag will be added to cq. If the alarm expired, the event's success bit will be true, false otherwise (ie, upon cancellation).


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