2003-02-25 18:56:09 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/**
|
|
|
|
|
* \file forkedcallqueue.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Alfredo Braunstein (based on an idea from Angus Leeming)
|
2003-06-30 23:56:22 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-06-30 23:56:22 +00:00
|
|
|
|
*
|
|
|
|
|
* This class implements a queue of forked processes. In order not to
|
|
|
|
|
* hose the system with multiple processes running simultaneously, you can
|
|
|
|
|
* request the addition of your process to this queue and it will be
|
2003-02-25 18:56:09 +00:00
|
|
|
|
* executed when its turn comes.
|
2003-06-30 23:56:22 +00:00
|
|
|
|
*
|
2003-02-25 18:56:09 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef FORKEDCALLQUEUE_H
|
|
|
|
|
#define FORKEDCALLQUEUE_H
|
|
|
|
|
|
|
|
|
|
#include "forkedcall.h"
|
|
|
|
|
|
|
|
|
|
#include <queue>
|
|
|
|
|
#include <utility>
|
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
namespace support {
|
|
|
|
|
|
2003-02-25 18:56:09 +00:00
|
|
|
|
class ForkedCallQueue {
|
|
|
|
|
public:
|
|
|
|
|
/// A process in the queue
|
|
|
|
|
typedef std::pair<string, Forkedcall::SignalTypePtr> Process;
|
|
|
|
|
/**<2A>Add<64>a<EFBFBD>process<73>to<74>the<68>queue.<2E>Processes<65>are<72>forked<65>sequentially
|
|
|
|
|
*<EFBFBD><EFBFBD>only<EFBFBD>one<EFBFBD>is<EFBFBD>running<EFBFBD>at<EFBFBD>a<EFBFBD>time.
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*<EFBFBD><EFBFBD>Connect<EFBFBD>to<EFBFBD>the<EFBFBD>returned<EFBFBD>signal<EFBFBD>and<EFBFBD>you'll<EFBFBD>be<EFBFBD>informed<EFBFBD>when
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*<EFBFBD><EFBFBD>the<EFBFBD>process<EFBFBD>has<EFBFBD>ended.
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
Forkedcall::SignalTypePtr add(string const & process);
|
|
|
|
|
///<2F>Query<72>whether<65>the<68>queue<75>is<69>running<6E>a<EFBFBD>forked<65>process<73>now.
|
|
|
|
|
bool running() const;
|
|
|
|
|
/// Get the and only instance of the class
|
|
|
|
|
static ForkedCallQueue & get();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
|
/** this class is a singleton class... use
|
2003-02-25 18:56:09 +00:00
|
|
|
|
* ForkedCallQueue::get() instead
|
|
|
|
|
*/
|
|
|
|
|
ForkedCallQueue();
|
2003-06-30 23:56:22 +00:00
|
|
|
|
/// in-progress queue
|
2003-02-25 18:56:09 +00:00
|
|
|
|
std::queue<Process> callQueue_;
|
|
|
|
|
///
|
|
|
|
|
bool running_;
|
|
|
|
|
///
|
|
|
|
|
void callNext();
|
|
|
|
|
///
|
|
|
|
|
void startCaller();
|
|
|
|
|
///
|
|
|
|
|
void stopCaller();
|
|
|
|
|
///
|
|
|
|
|
void callback(pid_t, int);
|
|
|
|
|
};
|
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
|
} // namespace support
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2003-02-25 18:56:09 +00:00
|
|
|
|
#endif // FORKEDCALLQUEUE_H
|