X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fcommon%2Ffile-descriptor-monitor.h;h=508f37f7b2eaae0d4e3f37aef67fd97f45465e7c;hb=ab5a19a8b72cc2dd6e1573df1f37ce25be584d09;hp=9ffd738434174568c2094b8777a45020490a99fe;hpb=51f367d9592772c9fa82ee02b60a654325bc0005;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/common/file-descriptor-monitor.h b/adaptors/common/file-descriptor-monitor.h index 9ffd738..508f37f 100644 --- a/adaptors/common/file-descriptor-monitor.h +++ b/adaptors/common/file-descriptor-monitor.h @@ -44,12 +44,50 @@ class FileDescriptorMonitor public: /** - * Constructor - * @param[in] fileDescriptor The file descriptor to monitor - * @param[in] callback Called when anything is written to the file descriptor + * @brief Bitmask of file descriptor event types + */ + enum EventType + { + FD_NO_EVENT = 0x0, + FD_READABLE = 0x1, // For example when monitoring a socket, data is available to read from the socket receive buffer + FD_WRITABLE = 0x2, // For example when monitoring a socket space is available in socket send buffer + FD_ERROR = 0x4, + }; + + /** + * @brief Constructor. + * + * The callback will be passed a EventType bitmask to signal what type of events occured on the file + * descriptor. + * Example: + * + * MyClass::MyClass() + * { + * mFileDescriptorMonitor = new FileDescriptorMonitor( myFd, MakeCallback( this, &MyClass::FdCallback ), FileDescriptorMonitor::FD_READABLE ); + * } + * + * void MyClass::FdCallback( EventType event ) + * { + * if( event & FileDescriptorMonitor::FD_ERROR) + * { + * LOG_ERROR("...) + * } + * if( event & FileDescriptorMonitor::FD_READABLE ) + * { + * // read from FD + * } + * + * } + * + * @param[in] fileDescriptor The file descriptor to monitor + * @param[in] callback Called when anything is written to the file descriptor + * @param[in] eventBitmask Bitmask of what to monitor on the file descriptor ( readable / writable ). * @note The ownership of callback is taken by this class. + * @note Under Linux it is possible the file descriptor monitor will signal a fd is + * readable or writable even when it isn’t. The developer should check for handle EAGAIN or equivalent + * when reading from or write to the fd. */ - FileDescriptorMonitor( int fileDescriptor, CallbackBase* callback ); + FileDescriptorMonitor( int fileDescriptor, CallbackBase* callback, int eventBitmask ); /** * Destructor