AsyncFw 1.2
Async Framework is c++ runtime with timers, poll notifiers, sockets, coroutines, etc.
 
Loading...
Searching...
No Matches
AsyncFw::PollNotifier Class Reference

The PollNotifier class Example: More...

#include <AsyncFw/PollNotifier>

Collaboration diagram for AsyncFw::PollNotifier:
[legend]

Public Member Functions

 PollNotifier (int, AbstractThread::PollEvents=AbstractThread::PollIn)
 Constructs a poll notifier. It assigns the file descriptor, and watches for events.
 
bool setDescriptor (int, AbstractThread::PollEvents=AbstractThread::PollIn)
 Assigns the file descriptor and watch events.
 
bool setEvents (AbstractThread::PollEvents)
 Set watch events.
 
void removeDescriptor ()
 Remove the file descriptor.
 
int descriptor ()
 Returns the file descriptor.
 
bool fail ()
 Returns true if error occurred.
 

Public Attributes

FunctionConnectorProtected< PollNotifier >::Connector< AbstractThread::PollEvents > notify
 The PollNotifier::notify connector.
 

Detailed Description

The PollNotifier class Example:

/*
* This exfample for Unix-like systems only
*/
#include <iostream>
#include <AsyncFw/MainThread>
#include <AsyncFw/PollNotifier>
int main(int argc, char *argv[]) {
AsyncFw::PollNotifier notifier(STDIN_FILENO);
notifier.notify([&notifier](AsyncFw::AbstractThread::PollEvents e) {
char buf[128];
int r = read(STDIN_FILENO, buf, sizeof(buf) - 1);
buf[r] = 0;
if (r == 2 && buf[0] == 'q') AsyncFw::MainThread::exit();
(std::cout << "stdin: " << buf).flush();
});
(std::cout << "Start Applicaiton" << std::endl).flush();
int ret = AsyncFw::MainThread::exec();
return ret;
}

Constructor & Destructor Documentation

◆ PollNotifier()

PollNotifier::PollNotifier ( int fd,
AbstractThread::PollEvents events = AbstractThread::PollIn )

Constructs a poll notifier. It assigns the file descriptor, and watches for events.

Parameters
fdfile descriptor
eventswatch events
Here is the call graph for this function:

Member Function Documentation

◆ setDescriptor()

bool PollNotifier::setDescriptor ( int fd,
AbstractThread::PollEvents events = AbstractThread::PollIn )

Assigns the file descriptor and watch events.

Parameters
fdfile descriptor
eventswatch events
Returns
True if descriptor is set
Here is the caller graph for this function:

◆ setEvents()

bool PollNotifier::setEvents ( AbstractThread::PollEvents events)

Set watch events.

Parameters
eventswatch events
Returns
True if events is set

The documentation for this class was generated from the following files: