Listener.h
/*
* $Id: Listener.h 2839 2009-09-28 11:36:20Z karijes $
*
* Descriptor monitoring functions
* Copyright (c) 2008 edelib authors
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __EDELIB_LISTENER_H__
#define __EDELIB_LISTENER_H__
#include "edelib-global.h"
EDELIB_NS_BEGIN
enum {
LISTENER_READ = 1,
LISTENER_WRITE = 4,
LISTENER_EXCEPT = 8
};
EDELIB_API void listener_add_fd(int fd, int when, void(*cb)(int, void*), void* arg = 0);
EDELIB_API inline void listener_add_fd(int fd, void(*cb)(int, void*), void* arg = 0) {
listener_add_fd(fd, LISTENER_READ, cb, arg);
}
EDELIB_API void listener_remove_fd(int fd, int when);
EDELIB_API inline void listener_remove_fd(int fd) {
listener_remove_fd(fd, LISTENER_READ);
}
EDELIB_API double listener_wait(double t);
EDELIB_API inline int listener_wait(void) {
// FLTK uses 1e20 for forever so I'm using it too
return (int)listener_wait(1e20);
}
EDELIB_NS_END
#endif
edelib::LISTENER_WRITE
callback is called when there is data to be written without blocking
Definition: Listener.h:30
edelib::listener_add_fd
void listener_add_fd(int fd, int when, void(*cb)(int, void *), void *arg=0)
edelib::listener_wait
double listener_wait(double t)
edelib::LISTENER_READ
callback is called when there is data to be read
Definition: Listener.h:29
edelib::listener_remove_fd
void listener_remove_fd(int fd, int when)
edelib::LISTENER_EXCEPT
callback is called when exception happens on descriptor
Definition: Listener.h:31