documentation for class WQueue and Notify added.

This commit is contained in:
Roland Jax
2014-11-16 10:08:58 +01:00
parent 5db9c5c774
commit e4e709ec6a
4 changed files with 101 additions and 19 deletions
+22 -13
View File
@@ -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;
};