pnoltes commented on code in PR #583:
URL: https://github.com/apache/celix/pull/583#discussion_r1251166886


##########
libs/framework/include/celix/ScheduledEvent.h:
##########
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include "celix_bundle_context.h"
+
+namespace celix {
+
+/**
+ * @brief 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.
+ */
+class ScheduledEvent final {
+  public:
+    friend class ScheduledEventBuilder;
+
+    /**
+     * @brief Constructs a empty / not-active scheduled event.
+     *
+     * During destruction the scheduled event will be removed asynchronously 
from the bundle context.
+     */
+    ScheduledEvent() = default;
+
+    /**
+     * @brief Destroys the scheduled event by removes it from the bundle 
context if it is not a one-short event.
+     */
+    ~ScheduledEvent() noexcept {
+        if (!isOneShot) {
+            celix_bundleContext_tryRemoveScheduledEventAsync(ctx.get(), 
eventId);
+        }
+    }
+
+    ScheduledEvent(const ScheduledEvent&) = delete;
+    ScheduledEvent& operator=(const ScheduledEvent&) = delete;
+
+    ScheduledEvent(ScheduledEvent&&) noexcept = default;

Review Comment:
   update the move semantics



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to