1 /* This file is part of Pazpar2.
2 Copyright (C) 2006-2009 Index Data
4 Pazpar2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <yaz/yconfig.h>
26 /** \brief select thread handler type */
27 typedef struct sel_thread *sel_thread_t;
29 /** \brief creates select thread
30 \param work_handler handler that does work in worker thread
31 \param work_destroy optional destroy handler for work (0 = no handler)
32 \param read_fd pointer to readable socket upon completion
33 \param no_of_threads number of worker threads
34 \returns select thread handler
36 Creates a worker thread. The worker thread will signal "completed"
37 work by sending one byte to the read_fd file descriptor.
38 You are supposed to select or poll on that for reading and
39 call sel_thread_result accordingly.
41 sel_thread_t sel_thread_create(void (*work_handler)(void *work_data),
42 void (*work_destroy)(void *work_data),
43 int *read_fd, int no_of_threads);
45 /** \brief destorys select thread
46 \param p select thread handler
48 void sel_thread_destroy(sel_thread_t p);
50 /** \brief adds work to be carried out in thread
51 \param p select thread handler
52 \param data pointer to data that work_handler knows about
54 void sel_thread_add(sel_thread_t p, void *data);
56 /** \brief gets result of work
57 \param p select thread handler
58 \returns data for work (which work_handler has been working on)
60 void *sel_thread_result(sel_thread_t p);
71 * indent-tabs-mode: nil
73 * vim: shiftwidth=4 tabstop=8 expandtab