kodi
LanguageInvokerThread.h
1 /*
2  * Copyright (C) 2013-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "interfaces/generic/ILanguageInvoker.h"
12 #include "threads/Thread.h"
13 
14 #include <string>
15 #include <vector>
16 
18 
20 {
21 public:
22  CLanguageInvokerThread(LanguageInvokerPtr invoker,
23  CScriptInvocationManager* invocationManager,
24  bool reuseable);
25  ~CLanguageInvokerThread() override;
26 
27  virtual InvokerState GetState() const;
28 
29  const std::string& GetScript() const { return m_script; }
30  LanguageInvokerPtr GetInvoker() const { return m_invoker; }
31  bool Reuseable(const std::string& script) const
32  {
33  return !m_bStop && m_reusable && GetState() == InvokerStateScriptDone && m_script == script;
34  };
35  virtual void Release();
36 
37 protected:
38  bool execute(const std::string &script, const std::vector<std::string> &arguments) override;
39  bool stop(bool wait) override;
40 
41  void OnStartup() override;
42  void Process() override;
43  void OnExit() override;
44  void OnException() override;
45 
46 private:
47  LanguageInvokerPtr m_invoker;
48  CScriptInvocationManager *m_invocationManager;
49  std::string m_script;
50  std::vector<std::string> m_args;
51 
52  std::mutex m_mutex;
53  std::condition_variable m_condition;
54  bool m_restart = false;
55  bool m_reusable = false;
56 };
Definition: LanguageInvokerThread.h:19
Definition: Thread.h:44
Definition: ScriptInvocationManager.h:23
Definition: ILanguageInvoker.h:31