Add the skeleton of WakeLock, which keeps the AP awake iff at least one instance... 91/139891/3
authorMu-Woong Lee <muwoong.lee@samsung.com>
Fri, 21 Jul 2017 02:30:13 +0000 (11:30 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Fri, 21 Jul 2017 02:59:04 +0000 (11:59 +0900)
Change-Id: I0acba5ca9340b2135cd310b9150571735e6c78ec
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
include/WakeLock.h [new file with mode: 0644]
src/server/WakeLock.cpp [new file with mode: 0644]

diff --git a/include/WakeLock.h b/include/WakeLock.h
new file mode 100644 (file)
index 0000000..e4449ac
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed 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.
+ */
+
+#ifndef __CONTEXT_WAKE_LOCK_H__
+#define __CONTEXT_WAKE_LOCK_H__
+
+#include <ContextTypes.h>
+
+namespace ctx {
+
+       class EXPORT_API WakeLock {
+       public:
+               WakeLock();
+               ~WakeLock();
+       };
+
+}
+
+#endif /* __CONTEXT_WAKE_LOCK_H__ */
diff --git a/src/server/WakeLock.cpp b/src/server/WakeLock.cpp
new file mode 100644 (file)
index 0000000..155f2fc
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed 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.
+ */
+
+#include <atomic>
+#include <WakeLock.h>
+
+using namespace ctx;
+
+static std::atomic_uint __refCount(0);
+
+static void __acquire()
+{
+       _I("Acquiring a WakeLock");
+       // TODO
+}
+
+static void __release()
+{
+       _I("Releasing the WakeLock");
+       // TODO
+}
+
+WakeLock::WakeLock()
+{
+       if (__refCount++ == 0)
+               __acquire();
+
+       _D("#wakelocks: %u", __refCount.load());
+}
+
+WakeLock::~WakeLock()
+{
+       if (__refCount-- == 1)
+               __release();
+
+       _D("#wakelocks: %u", __refCount.load());
+}