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>
23 ForkedCallQueue & ForkedCallQueue::get()
25 static ForkedCallQueue singleton;
30 Forkedcall::SignalTypePtr ForkedCallQueue::add(string const & process)
32 Forkedcall::SignalTypePtr ptr;
33 ptr.reset(new Forkedcall::SignalType);
34 callQueue_.push(Process(process, ptr));
42 void ForkedCallQueue::callNext()
44 if (callQueue_.empty())
46 Process pro = callQueue_.front();
48 // Bind our chain caller
49 pro.second->connect(boost::bind(&ForkedCallQueue::callback,
52 // If we fail to fork the process, then emit the signal
53 // to tell the outside world that it failed.
54 if (call.startscript(pro.first, pro.second) > 0) {
55 pro.second->operator()(0,1);
60 void ForkedCallQueue::callback(pid_t, int)
62 if(callQueue_.empty()) {
69 ForkedCallQueue::ForkedCallQueue() : running_(false)
73 void ForkedCallQueue::startCaller()
75 lyxerr[Debug::GRAPHICS] << "ForkedCallQueue: waking up" << endl;
81 void ForkedCallQueue::stopCaller()
84 lyxerr[Debug::GRAPHICS] << "ForkedCallQueue: I'm going to sleep"
89 bool ForkedCallQueue::running() const