Loading...
Searching...
No Matches
juce_ChildProcessManager.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
class JUCE_API ChildProcessManager final : private DeletedAtShutdown
{
public:
#ifndef DOXYGEN
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (ChildProcessManager)
#endif
template <typename... Args>
std::shared_ptr<ChildProcess> createAndStartManagedChildProcess (Args&&... args)
{
auto p = std::make_shared<ChildProcess>();
if (! p->start (std::forward<Args> (args)...))
return nullptr;
processes.insert (p);
timer.startTimer (1000);
return p;
}
auto addChildProcessExitedListener (std::function<void (ChildProcess*)> listener)
{
return listeners.addListener (std::move (listener));
}
auto hasRunningProcess() const
{
return timer.isTimerRunning();
}
private:
ChildProcessManager() = default;
~ChildProcessManager() override { clearSingletonInstance(); }
void checkProcesses();
std::set<std::shared_ptr<ChildProcess>> processes;
detail::CallbackListenerList<ChildProcess*> listeners;
TimedCallback timer { [this] { checkProcesses(); } };
};
} // namespace juce
juce::ChildProcessManager
Definition juce_ChildProcessManager.h:48
juce::ChildProcessManager::addChildProcessExitedListener
auto addChildProcessExitedListener(std::function< void(ChildProcess *)> listener)
Definition juce_ChildProcessManager.h:80
juce::ChildProcessManager::hasRunningProcess
auto hasRunningProcess() const
Definition juce_ChildProcessManager.h:88
juce::ChildProcessManager::createAndStartManagedChildProcess
std::shared_ptr< ChildProcess > createAndStartManagedChildProcess(Args &&... args)
Definition juce_ChildProcessManager.h:63
juce::ChildProcess
Definition juce_ChildProcess.h:36
juce::DeletedAtShutdown::DeletedAtShutdown
DeletedAtShutdown()
Definition juce_DeletedAtShutdown.cpp:34