terminator.h
来自「一个语言识别引擎」· C头文件 代码 · 共 94 行
H
94 行
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
/*
* Copyright (C) 2006 Giorgio Metta
* CopyPolicy: Released under the terms of the GNU GPL v2.0.
*
*/
#ifndef __TERMINATORH__
#define __TERMINATORH__
// $Id: Terminator.h,v 1.10 2006/10/24 19:14:48 eshuy Exp $
#include <yarp/os/Thread.h>
namespace yarp {
namespace os {
class Terminator;
class Terminee;
}
}
/**
* \file Terminator.h classes to handle graceful process termination.
*/
/**
* Send a message to a process that has a corresponding
* socket port created using the Terminee class to ask to start
* a graceful quit procedure. The receiving process must
* collaborate and take appropriate action after receiving the
* message. The Terminator/Terminee class pair starts a tcp socket on the
* server side listening for incoming connections and the magic word "quit"
* (all lowercase). The ip-port pair is registered with a symbolic name
* on the Yarp name server and can be queried by the client to send the
* termination message.
*/
class yarp::os::Terminator {
public:
/**
* Send a quit message to a specific socket port.
* @param name is the name of the socket port (as registered in
* the name server).
* @return true/false on success/failure.
*/
static bool terminateByName(const char *name);
};
/**
* A class that can be polled to see whether the process has been
* asked to quit gracefully.
*/
class yarp::os::Terminee : public yarp::os::Thread {
protected:
void *implementation;
volatile bool quit;
volatile bool ok;
public:
/**
* Constructor.
* @param name is the nickname to register on the name server.
*/
Terminee(const char *name);
/**
* Destructor.
*/
virtual ~Terminee();
virtual void run();
// LATER: mustQuitBlocking() to wait on a semaphore.
/**
* Call this method to see whether a quit message has
* been received.
* @return true is a quit has been received, false otherwise.
*/
bool mustQuit() const { return quit; }
/**
* Check whether the message mechanism is ok.
* @return true if ok, false otherwise.
*/
bool isOk() const { return ok; }
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?