/* ==========================================================================
* libevnet/src/thread.h - Network server library for libevent.
* --------------------------------------------------------------------------
* Copyright (c) 2006 William Ahern
* Copyright (c) 2005 Barracuda Networks, Inc.
* Copyright (c) 2002 William Ahern (Originally under GPL from AnonNet.)
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
* ==========================================================================
*/
#ifndef EVNET_THREAD_H
#define EVNET_THREAD_H
#include <signal.h> /* sigset_t */
#define THREAD_SUCCESS(e) (!THREAD_FAILURE((e)))
#define THREAD_FAILURE(e) ((e) != THREAD_ESUCCESS)
enum thread_errno {
THREAD_ESUCCESS,
THREAD_ESYSTEM,
THREAD_ETIMEDOUT,
};
enum thread_priority {
THREAD_PRI_LOW = 0,
THREAD_PRI_NORM = 5,
THREAD_PRI_HIGH = 10
};
struct thread_options {
unsigned nthreads_min;
unsigned nthreads_max;
int nthreads_fixed;
int sigmask_how;
#ifndef WIN32
sigset_t sigmask_set;
#endif
};
#ifdef LIBEVNET_SOURCE
extern struct thread_options thread_defaults;
#else
extern const struct thread_options thread_defaults;
#endif
typedef void *(*thread_enter)(void *, void *, unsigned);
typedef void (*thread_return)(void *, enum thread_errno, void *);
void thread_run(thread_enter, void *, enum thread_priority, thread_return, void *, unsigned);
const char *thread_strerror(enum thread_errno);
struct event_base;
enum thread_errno thread_reset(const struct thread_options *opts, struct event_base *);
enum thread_errno thread_init(const struct thread_options *opts, struct event_base *);
#endif /* EVNET_THREAD_H */
syntax highlighted by Code2HTML, v. 0.9.1