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
11 #include "forkedcallqueue.h"
15 #include <boost/bind.hpp>
16 #include <boost/signals/signal2.hpp>
21 ForkedCallQueue & ForkedCallQueue::get()
23 static ForkedCallQueue singleton;
28 Forkedcall::SignalTypePtr ForkedCallQueue::add(string const & process)
30 Forkedcall::SignalTypePtr ptr;
31 ptr.reset(new Forkedcall::SignalType);
32 callQueue_.push(Process(process, ptr));
40 void ForkedCallQueue::callNext()
42 if (callQueue_.empty())
44 Process pro = callQueue_.front();
46 // Bind our chain caller
47 pro.second->connect(boost::bind(&ForkedCallQueue::callback,
50 // If we fail to fork the process, then emit the signal
51 // to tell the outside world that it failed.
52 if (call.startscript(pro.first, pro.second) > 0) {
53 pro.second->operator()(0,1);
58 void ForkedCallQueue::callback(pid_t, int)
60 if(callQueue_.empty()) {
67 ForkedCallQueue::ForkedCallQueue() : running_(false)
71 void ForkedCallQueue::startCaller()
73 lyxerr[Debug::GRAPHICS] << "ForkedCallQueue: waking up" << endl;
79 void ForkedCallQueue::stopCaller()
82 lyxerr[Debug::GRAPHICS] << "ForkedCallQueue: I'm going to sleep"
87 bool ForkedCallQueue::running() const