documentation for class WQueue and Notify added.
This commit is contained in:
+22
-13
@@ -23,30 +23,39 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/**
|
||||
* @brief class to notify other thread per pipe.
|
||||
*/
|
||||
class Notify
|
||||
{
|
||||
|
||||
public:
|
||||
Notify()
|
||||
{
|
||||
int pipefd[2];
|
||||
int ret = pipe(pipefd);
|
||||
/**
|
||||
* @brief constructs a new instance and do notifying.
|
||||
*/
|
||||
Notify();
|
||||
|
||||
if (ret == 0) {
|
||||
m_recvfd = pipefd[0];
|
||||
m_sendfd = pipefd[1];
|
||||
/**
|
||||
* @brief destructor.
|
||||
*/
|
||||
~Notify();
|
||||
|
||||
fcntl(m_sendfd, F_SETFL, O_NONBLOCK);
|
||||
}
|
||||
/**
|
||||
* @brief file descriptor to watch for notify event.
|
||||
* @return the notification value
|
||||
*/
|
||||
int notifyFD() { return m_recvfd; }
|
||||
|
||||
}
|
||||
virtual ~Notify() { close(m_sendfd); close(m_recvfd); }
|
||||
|
||||
int notifyFD() const { return m_recvfd; }
|
||||
/**
|
||||
* @brief write notify event to file descriptor.
|
||||
* @return result of writing notification
|
||||
*/
|
||||
int notify() const { return write(m_sendfd,"1",1); }
|
||||
|
||||
private:
|
||||
/** file descriptor to watch */
|
||||
int m_recvfd;
|
||||
/** file descriptor to notify */
|
||||
int m_sendfd;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user