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>
26 ForkedCallQueue & ForkedCallQueue::get()
28 static ForkedCallQueue singleton;
33 Forkedcall::SignalTypePtr ForkedCallQueue::add(string const & process)
35 Forkedcall::SignalTypePtr ptr;
36 ptr.reset(new Forkedcall::SignalType);
37 callQueue_.push(Process(process, ptr));
45 void ForkedCallQueue::callNext()
47 if (callQueue_.empty())
49 Process pro = callQueue_.front();
51 // Bind our chain caller
52 pro.second->connect(boost::bind(&ForkedCallQueue::callback,
55 // If we fail to fork the process, then emit the signal
56 // to tell the outside world that it failed.
57 if (call.startscript(pro.first, pro.second) > 0) {
58 pro.second->operator()(0,1);
63 void ForkedCallQueue::callback(pid_t, int)
65 if(callQueue_.empty()) {
72 ForkedCallQueue::ForkedCallQueue() : running_(false)
76 void ForkedCallQueue::startCaller()
78 lyxerr[Debug::GRAPHICS] << "ForkedCallQueue: waking up" << endl;
84 void ForkedCallQueue::stopCaller()
87 lyxerr[Debug::GRAPHICS] << "ForkedCallQueue: I'm going to sleep"
92 bool ForkedCallQueue::running() const
97 } // namespace support