blob: c89c9f79f443ecef4bc27a0b0350f6290d2d81a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/*
* Copyright (C) 2017-2021 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "RunningScriptObserver.h"
#include "interfaces/generic/ScriptInvocationManager.h"
using namespace std::chrono_literals;
CRunningScriptObserver::CRunningScriptObserver(int scriptId, CEvent& evt)
: m_scriptId(scriptId), m_event(evt), m_stopEvent(true), m_thread(this, "ScriptObs")
{
m_thread.Create();
}
CRunningScriptObserver::~CRunningScriptObserver()
{
Abort();
}
void CRunningScriptObserver::Run()
{
do
{
if (!CScriptInvocationManager::GetInstance().IsRunning(m_scriptId))
{
m_event.Set();
break;
}
} while (!m_stopEvent.Wait(20ms));
}
void CRunningScriptObserver::Abort()
{
m_stopEvent.Set();
m_thread.StopThread();
}
|