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 "support/forkedcallqueue.h"
17 #include <boost/bind.hpp>
27 ForkedCallQueue & ForkedCallQueue::get()
29 static ForkedCallQueue singleton;
34 Forkedcall::SignalTypePtr ForkedCallQueue::add(string const & process)
36 Forkedcall::SignalTypePtr ptr;
37 ptr.reset(new Forkedcall::SignalType);
38 callQueue_.push(Process(process, ptr));
46 void ForkedCallQueue::callNext()
48 if (callQueue_.empty())
50 Process pro = callQueue_.front();
52 // Bind our chain caller
53 pro.second->connect(boost::bind(&ForkedCallQueue::callback,
56 // If we fail to fork the process, then emit the signal
57 // to tell the outside world that it failed.
58 if (call.startscript(pro.first, pro.second) > 0) {
59 pro.second->operator()(0,1);
64 void ForkedCallQueue::callback(pid_t, int)
66 if (callQueue_.empty()) {
73 ForkedCallQueue::ForkedCallQueue() : running_(false)
77 void ForkedCallQueue::startCaller()
79 lyxerr[Debug::GRAPHICS] << "ForkedCallQueue: waking up" << endl;
85 void ForkedCallQueue::stopCaller()
88 lyxerr[Debug::GRAPHICS] << "ForkedCallQueue: I'm going to sleep"
93 bool ForkedCallQueue::running() const
98 } // namespace support