IONotifier Class Reference

#include <Pt/System/IONotifier.h>

Monitors a native handle or file descriptor. More...

Inherits Selectable.

Public Types

enum  WaitFlags {
  Read = 1,
  Write = 2,
  Except = 4
}
 

Public Member Functions

 IONotifier ()
 Default constructor.
 
 IONotifier (void *handle)
 Construct with a native handle.
 
 IONotifier (int fd)
 Construct with a file descriptor.
 
 ~IONotifier ()
 Destructor.
 
void reset ()
 Clears the handle or file descriptor.
 
void setFd (int fd)
 Sets the file descriptor to monitor.
 
void setHandle (void *handle)
 Sets the native handle to monitor.
 
void beginWait (int flags)
 Begins monitoring for flags.
 
int endWait ()
 Ends monitoring and returns the ready flags.
 
Pt::SignaleventReady ()
 Notifies when the handle or descriptor is ready.
 
EventLooploop () const
 Returns the used event loop.
 
void setActive (EventLoop &parent)
 Sets the parent loop, so that operations can be run.
 
void detach ()
 Remove from event loop and cancels outstanding operations.
 
void cancel ()
 Cancels all operations.
 
bool run ()
 Run operation if it is ready.
 
EventLoopparent () const
 Returns the used event loop.
 

Protected Member Functions

virtual void onAttach (EventLoop &loop)
 Attached to loop.
 
virtual void onDetach (EventLoop &loop)
 Detached from loop.
 
virtual void onCancel ()
 Blocks until operation has cancelled.
 
virtual bool onRun ()
 Check if ready and run.
 
void post ()
 Posts this selectable to its event loop from any thread.
 

Detailed Description

IONotifier is a Selectable that reports activity on a native endpoint the rest of the I/O API does not own. setHandle() names a Windows handle. setFd() names a POSIX file descriptor. The constructor can pass either.

Attach the notifier to an EventLoop with setActive(). beginWait() starts monitoring for a combination of WaitFlags. When the loop sees activity, eventReady is emitted. endWait() returns the flags that are ready. reset() clears the handle or descriptor.

Use this type when the endpoint is not an IODevice: a socket created outside Pt, or a handle from another library.

Member Enumeration Documentation

◆ WaitFlags

enum WaitFlags
Enumerator
Read 

Readable.

Write 

Writable.

Except 

Exceptional condition.