Apache Celix  latest
Apache Celix is a framework for C, C++14 and C++17 to develop dynamic modular software applications using component and in-process service-oriented programming.
Classes | Public Member Functions | Friends | List of all members
celix::ScheduledEvent Class Referencefinal

A C++ abstraction for a scheduled event in Celix. More...

#include <ScheduledEvent.h>

Public Member Functions

 ScheduledEvent ()=default
 Constructs a empty / not-active scheduled event. More...
 
 ~ScheduledEvent () noexcept
 Destroys the scheduled event by removes it from the bundle context if it is not a one-short event. More...
 
 ScheduledEvent (const ScheduledEvent &)=delete
 
ScheduledEventoperator= (const ScheduledEvent &)=delete
 
 ScheduledEvent (ScheduledEvent &&rhs) noexcept
 
ScheduledEventoperator= (ScheduledEvent &&rhs) noexcept
 
void cancel ()
 Cancels the scheduled event. More...
 
void wakeup ()
 Wakeup a scheduled event and returns immediately, not waiting for the scheduled event callback to be called. More...
 
template<typename Rep , typename Period >
bool waitFor (std::chrono::duration< Rep, Period > waitTime)
 Wait until the next scheduled event is processed. More...
 

Friends

class ScheduledEventBuilder
 

Detailed Description

A C++ abstraction for a scheduled event in Celix.

A scheduled event is an event that is scheduled to be executed at a certain initial delay and/or interval. A new scheduld event should be created using celix::BundleContext::createScheduledEvent.

This class uses RAII to automatically remove the (non one-shot) scheduled event from the bundle context when it is destroyed. For one-shot scheduled events, the destructor will not remove the scheduled event.

Constructor & Destructor Documentation

◆ ScheduledEvent() [1/3]

celix::ScheduledEvent::ScheduledEvent ( )
default

Constructs a empty / not-active scheduled event.

During destruction the scheduled event will be removed asynchronously from the bundle context.

◆ ~ScheduledEvent()

celix::ScheduledEvent::~ScheduledEvent ( )
inlinenoexcept

Destroys the scheduled event by removes it from the bundle context if it is not a one-short event.

◆ ScheduledEvent() [2/3]

celix::ScheduledEvent::ScheduledEvent ( const ScheduledEvent )
delete

◆ ScheduledEvent() [3/3]

celix::ScheduledEvent::ScheduledEvent ( ScheduledEvent &&  rhs)
inlinenoexcept

Member Function Documentation

◆ cancel()

void celix::ScheduledEvent::cancel ( )
inline

Cancels the scheduled event.

This method will block until a possible in-progress scheduled event callback is finished, the scheduled event is removed and, if configured, the remove callback is called. Should not be called multiple times.

◆ operator=() [1/2]

ScheduledEvent& celix::ScheduledEvent::operator= ( const ScheduledEvent )
delete

◆ operator=() [2/2]

ScheduledEvent& celix::ScheduledEvent::operator= ( ScheduledEvent &&  rhs)
inlinenoexcept

◆ waitFor()

template<typename Rep , typename Period >
bool celix::ScheduledEvent::waitFor ( std::chrono::duration< Rep, Period >  waitTime)
inline

Wait until the next scheduled event is processed.

Template Parameters
RepThe representation type of the duration.
PeriodThe period type of the duration.
Parameters
[in]waitTimeThe maximum time to wait for the next scheduled event. If <= 0 the function will return immediately.
Returns
true if the next scheduled event was processed, false if a timeout occurred.

◆ wakeup()

void celix::ScheduledEvent::wakeup ( )
inline

Wakeup a scheduled event and returns immediately, not waiting for the scheduled event callback to be called.

Friends And Related Function Documentation

◆ ScheduledEventBuilder

friend class ScheduledEventBuilder
friend

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