2 * \file forkedcallqueue.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alfredo Braunstein (based on an idea from Angus Leeming)
8 * Full author contact details are available in file CREDITS.
13 #include "forkedcallqueue.h"
17 #include <boost/bind.hpp>
18 #include <boost/signals/signal2.hpp>
28 ForkedCallQueue & ForkedCallQueue::get()
30 static ForkedCallQueue singleton;
35 Forkedcall::SignalTypePtr ForkedCallQueue::add(string const & process)
37 Forkedcall::SignalTypePtr ptr;
38 ptr.reset(new Forkedcall::SignalType);
39 callQueue_.push(Process(process, ptr));
47 void ForkedCallQueue::callNext()
49 if (callQueue_.empty())
51 Process pro = callQueue_.front();
53 // Bind our chain caller
54 pro.second->connect(boost::bind(&ForkedCallQueue::callback,
57 // If we fail to fork the process, then emit the signal
58 // to tell the outside world that it failed.
59 if (call.startscript(pro.first, pro.second) > 0) {
60 pro.second->operator()(0,1);
65 void ForkedCallQueue::callback(pid_t, int)
67 if (callQueue_.empty()) {
74 ForkedCallQueue::ForkedCallQueue() : running_(false)
78 void ForkedCallQueue::startCaller()
80 lyxerr[Debug::GRAPHICS] << "ForkedCallQueue: waking up" << endl;
86 void ForkedCallQueue::stopCaller()
89 lyxerr[Debug::GRAPHICS] << "ForkedCallQueue: I'm going to sleep"
94 bool ForkedCallQueue::running() const
99 } // namespace support