Set nice value -10 when making cache
[platform/core/appfw/pkgmgr-info.git] / src / server / request_handler / create_cache_request_handler.hh
1 // Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef CREATE_CACHE_REQUEST_HANDLER_HH_
6 #define CREATE_CACHE_REQUEST_HANDLER_HH_
7
8 #include "abstract_request_handler.hh"
9 #include "result_parcelable.hh"
10
11 #include <string>
12
13 namespace pkgmgr_server {
14 namespace request_handler {
15
16 #ifndef EXPORT_API
17 #define EXPORT_API __attribute__((visibility("default")))
18 #endif
19
20 class EXPORT_API CreateCacheRequestHandler : public AbstractRequestHandler {
21  public:
22   CreateCacheRequestHandler();
23   bool HandleRequest(const unsigned char* data, int size,
24       const std::string& locale) override;
25   std::vector<uint8_t> ExtractResult() override;
26
27   void PreExec() override;
28   void PostExec() override;
29
30  private:
31   class Scheduler {
32    public:
33     explicit Scheduler(pid_t tid);
34
35     void ChangePriority();
36     void ResetPriority();
37
38    private:
39     int Get(int* priority);
40     int Set(int priority);
41
42    private:
43     pid_t tid_;
44     int priority_;
45   };
46
47  private:
48   std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> result_;
49   Scheduler scheduler_;
50 };
51
52 }  // namespace request_handler
53 }  // namespace pkgmgr_server
54
55 #endif  // CREATE_CACHE_REQUEST_HANDLER_HH_