Fix inconsistency between cache and database
[platform/core/appfw/pkgmgr-info.git] / src / server / runner.hh
index b584259..6622f58 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2021 - 2022 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #define SERVER_RUNNER_HH_
 
 #include <gio/gio.h>
+#include <glib-unix.h>
 #include <vconf.h>
 
 #include <memory>
+#include <unordered_map>
 
+#include "create_cache_request.hh"
+#include "db_change_observer.hh"
 #include "server_socket.hh"
+#include "system_locale.hh"
 #include "worker_thread.hh"
 
 namespace pkgmgr_server {
@@ -31,20 +36,32 @@ namespace pkgmgr_server {
 #define EXPORT_API __attribute__((visibility("default")))
 #endif
 
-class EXPORT_API Runner {
+class EXPORT_API Runner : public pkgmgr_common::SystemLocale::IEvent,
+                          public pkgmgr_common::DbChangeObserver::IEvent,
+                          public CreateCacheRequest::IEvent {
  public:
-  Runner(int thread_num);
-  ~Runner() = default;
+  explicit Runner(unsigned int thread_num);
+  ~Runner();
+  bool QueueRequest(std::shared_ptr<PkgRequest> req);
+
+  void OnChanged(const std::string& locale) override;
+  void OnDbChanged() override;
+  void OnCreateCacheDone(bool success) override;
 
  private:
   static int OnReceiveRequest(int fd, GIOCondition cond, void* user_data);
-  static void OnLanguageChange(keynode_t* key, void* user_data);
   bool QueueRequest(int client_fd);
+  void SetCPUInheritance();
+  void SetCreateCacheTimer();
+  static gboolean RetryCreateCache(void* data);
 
  private:
-  int thread_num_;
+  int sid_;
+  unsigned int thread_num_;
+  uid_t default_uid_;
   std::unique_ptr<pkgmgr_common::socket::ServerSocket> server_;
   std::unique_ptr<WorkerThread> thread_pool_;
+  guint timer_ = 0;
 };
 
 }  // namespace pkgmgr_server