summaryrefslogtreecommitdiff
path: root/src/polling.hpp
blob: c0b242342a85bce78de5de09d661a658ed27e91b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 <http://www.gnu.org/licenses/>.
*/

#ifndef __XS_POLLING_HPP_INCLUDED__
#define __XS_POLLING_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