Apache Celix
2.4.0
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.
|
Go to the documentation of this file.
50 if (!isOneShot && ctx) {
59 : ctx{std::move(rhs.ctx)}, eventId{rhs.eventId}, isOneShot{rhs.isOneShot} {
65 ctx = std::move(rhs.ctx);
66 eventId = rhs.eventId;
67 isOneShot = rhs.isOneShot;
105 template <
typename Rep,
typename Period>
106 bool waitFor(std::chrono::duration<Rep, Period> waitTime) {
107 double waitTimeInSeconds = std::chrono::duration_cast<std::chrono::duration<double>>(waitTime).count();
108 celix_status_t status = CELIX_SUCCESS;
112 return status == CELIX_SUCCESS;
117 std::function<void()> callback{};
118 std::function<void()> removeCallback{};
121 static void (*callback)(
void*);
130 const std::string& _name,
131 std::function<
void()> _callback,
132 std::function<
void()> _removeCallback,
134 static auto callback = [](
void* data) {
135 auto* callbacks =
static_cast<Callbacks*
>(data);
136 (callbacks->callback)();
138 static auto removeCallback = [](
void* data) {
139 auto* callbacks =
static_cast<Callbacks*
>(data);
140 if (callbacks->removeCallback) {
141 (callbacks->removeCallback)();
146 ctx = std::move(_cCtx);
147 isOneShot = options.intervalInSeconds == 0;
148 options.name = _name.c_str();
149 auto* callbacks =
new Callbacks{std::move(_callback), std::move(_removeCallback)};
150 options.callbackData = callbacks;
152 options.removeCallbackData = callbacks;
157 std::shared_ptr<celix_bundle_context_t> ctx{};
159 bool isOneShot{
false};
CELIX_FRAMEWORK_EXPORT celix_status_t celix_bundleContext_wakeupScheduledEvent(celix_bundle_context_t *ctx, long scheduledEventId)
Wakeup a scheduled event and returns immediately, not waiting for the scheduled event callback to be ...
ScheduledEvent()=default
Constructs a empty / not-active scheduled event.
void(* callback)(void *callbackData) CELIX_OPTS_INIT
Callback function called to process a scheduled event. Will be called on the event thread.
Definition: celix_bundle_context.h:1307
CELIX_FRAMEWORK_EXPORT celix_status_t celix_bundleContext_waitForScheduledEvent(celix_bundle_context_t *ctx, long scheduledEventId, double waitTimeInSeconds)
Wait until the next scheduled event is processed.
A C++ builder for a ScheduledEvent object.
Definition: ScheduledEventBuilder.h:33
CELIX_FRAMEWORK_EXPORT bool celix_bundleContext_removeScheduledEvent(celix_bundle_context_t *ctx, long scheduledEventId)
Cancel and remove a scheduled event.
CELIX_FRAMEWORK_EXPORT bool celix_bundleContext_tryRemoveScheduledEventAsync(celix_bundle_context_t *ctx, long scheduledEventId)
Try to cancel and remove a scheduled event asynchronously.
void wakeup()
Wakeup a scheduled event and returns immediately, not waiting for the scheduled event callback to be ...
Definition: ScheduledEvent.h:90
CELIX_FRAMEWORK_EXPORT long celix_bundleContext_scheduleEvent(celix_bundle_context_t *ctx, const celix_scheduled_event_options_t *options)
Add a scheduled event to the Celix framework.
void(* removeCallback)(void *removeCallbackData) CELIX_OPTS_INIT
Callback function called when a scheduled event is removed. Will be called on the event thread.
Definition: celix_bundle_context.h:1313
ScheduledEvent(ScheduledEvent &&rhs) noexcept
Definition: ScheduledEvent.h:58
ScheduledEvent & operator=(const ScheduledEvent &)=delete
Celix scheduled event options, used for creating scheduling events with the celix framework.
Definition: celix_bundle_context.h:1292
~ScheduledEvent() noexcept
Destroys the scheduled event by removes it from the bundle context if it is not a one-short event.
Definition: ScheduledEvent.h:49
void cancel()
Cancels the scheduled event.
Definition: ScheduledEvent.h:80
A C++ abstraction for a scheduled event in Celix.
Definition: ScheduledEvent.h:35
bool waitFor(std::chrono::duration< Rep, Period > waitTime)
Wait until the next scheduled event is processed.
Definition: ScheduledEvent.h:106
ScheduledEvent & operator=(ScheduledEvent &&rhs) noexcept
Definition: ScheduledEvent.h:63