2 * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef LAUNCHPAD_PROCESS_POOL_PROCESS_POOL_HH_
18 #define LAUNCHPAD_PROCESS_POOL_PROCESS_POOL_HH_
21 #include <sys/types.h>
31 #include "launchpad-process-pool/executor.hh"
35 class ProcessPool : public Executor::Delegator,
40 virtual ~IEvent() = default;
41 virtual void OnRequestReceived(tizen_base::Parcel* parcel) = 0;
44 explicit ProcessPool(std::string name, int num_processes,
45 IEvent* event_listener);
46 virtual ~ProcessPool();
48 bool IsPrepared() const;
49 pid_t Execute(const tizen_base::Parcel& parcel);
56 Process(pid_t pid, int fd);
59 int Send(const tizen_base::Parcel& parcel);
64 std::unique_ptr<Socket> socket_;
67 void OnExecution() override;
69 void PrepareProcess();
70 int WaitForRequest(std::unique_ptr<Socket> socket);
71 static gboolean OnTimeout(gpointer user_data);
76 IEvent* event_listener_;
77 int pipe_fd_[2] = { -1, -1 };
78 std::queue<std::shared_ptr<Process>> queue_;
82 } // namespace launchpad
84 #endif // LAUNCHPAD_PROCESS_POOL_PROCESS_POOL_HH_