From 0fb5a016497d3061a6edf40752c06127f3abb796 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 20 Apr 2012 07:42:10 +0200 Subject: Select polling mechanisms at one place This patch provides a single place for selecting polling mechanisms (polling.hpp). Up to now the selection was spread among the build system and several source files. Signed-off-by: Martin Sustrik --- src/polling.hpp | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/polling.hpp (limited to 'src/polling.hpp') diff --git a/src/polling.hpp b/src/polling.hpp new file mode 100644 index 0000000..b8f0540 --- /dev/null +++ b/src/polling.hpp @@ -0,0 +1,68 @@ +/* + Copyright (c) 2012 250bpm s.r.o. + Copyright (c) 2012 Other contributors as noted in the AUTHORS file + + This file is part of Crossroads I/O project. + + Crossroads I/O 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 3 of the License, or + (at your option) any later version. + + Crossroads 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 program. If not, see . +*/ + +#ifndef __XS_CORE_HPP_INCLUDED__ +#define __XS_CORE_HPP_INCLUDED__ + +#include "platform.hpp" + +// This header file contains code that decides what polling mechanisms +// should be used in individual cases. It also includes appropriate headers. +// +// ASYNC polling mechanism to drive event loops in the I/O threads. +// SYNC polling mechanism is used in xs_poll() and for blocking API functions. + +#if defined XS_FORCE_SELECT +#define XS_USE_ASYNC_SELECT +#elif defined XS_FORCE_POLL +#define XS_USE_ASYNC_POLL +#elif defined XS_FORCE_EPOLL +#define XS_USE_ASYNC_EPOLL +#elif defined XS_FORCE_DEVPOLL +#define XS_USE_ASYNC_DEVPOLL +#elif defined XS_FORCE_KQUEUE +#define XS_USE_ASYNC_KQUEUE +#elif defined XS_HAVE_EPOLL +#define XS_USE_ASYNC_EPOLL +#elif defined XS_HAVE_DEVPOLL +#define XS_USE_ASYNC_DEVPOLL +#elif defined XS_HAVE_KQUEUE +#define XS_USE_ASYNC_KQUEUE +#elif defined XS_HAVE_POLL +#define XS_USE_ASYNC_POLL +#elif defined XS_HAVE_SELECT +#define XS_USE_ASYNC_SELECT +#else +#error No polling mechanism available! +#endif + +#if defined XS_FORCE_SELECT +#define XS_USE_SYNC_SELECT +#elif defined XS_FORCE_POLL +#define XS_USE_SYNC_POLL +#elif defined XS_HAVE_POLL +#define XS_USE_SYNC_POLL +#elif defined XS_HAVE_SELECT +#define XS_USE_SYNC_SELECT +#else +#error No polling mechanism available! +#endif + +#endif -- cgit v1.2.3