pazpar2
1.14.1
|
#include "sel_thread.h"
#include <yaz/log.h>
#include <yaz/nmem.h>
#include <stdlib.h>
#include <yaz/thread_create.h>
#include <yaz/mutex.h>
#include <yaz/spipe.h>
#include <assert.h>
Go to the source code of this file.
Data Structures | |
struct | work_item |
struct | sel_thread |
Functions | |
static struct work_item * | queue_remove_last (struct work_item **q) |
static void | queue_trav (struct work_item *q, void(*f)(void *data)) |
static void * | sel_thread_handler (void *vp) |
sel_thread_t | sel_thread_create (void(*work_handler)(void *work_data), void(*work_destroy)(void *work_data), int *read_fd, int no_of_threads) |
creates select thread More... | |
void | sel_thread_destroy (sel_thread_t p) |
destorys select thread More... | |
void | sel_thread_add (sel_thread_t p, void *data) |
adds work to be carried out in thread More... | |
void * | sel_thread_result (sel_thread_t p) |
gets result of work More... | |
Variables | |
static int | input_queue_length = 0 |
Definition at line 44 of file sel_thread.c.
References work_item::next.
Referenced by sel_thread_handler(), and sel_thread_result().
|
static |
Definition at line 58 of file sel_thread.c.
References work_item::data, and work_item::next.
Referenced by sel_thread_destroy().
void sel_thread_add | ( | sel_thread_t | p, |
void * | data | ||
) |
adds work to be carried out in thread
p | select thread handler |
data | pointer to data that work_handler knows about |
Definition at line 205 of file sel_thread.c.
References work_item::data, sel_thread::free_queue, sel_thread::input_data, sel_thread::input_queue, input_queue_length, sel_thread::mutex, work_item::next, and sel_thread::nmem.
Referenced by iochan_handler(), and run_fun().
sel_thread_t sel_thread_create | ( | void(*)(void *work_data) | work_handler, |
void(*)(void *work_data) | work_destroy, | ||
int * | read_fd, | ||
int | no_of_threads | ||
) |
creates select thread
work_handler | handler that does work in worker thread |
work_destroy | optional destroy handler for work (0 = no handler) |
read_fd | pointer to readable socket upon completion |
no_of_threads | number of worker threads |
Creates a worker thread. The worker thread will signal "completed" work by sending one byte to the read_fd file descriptor. You are supposed to select or poll on that for reading and call sel_thread_result accordingly.
Definition at line 129 of file sel_thread.c.
References sel_thread::free_queue, sel_thread::input_data, sel_thread::input_queue, sel_thread::mutex, sel_thread::nmem, sel_thread::no_threads, sel_thread::output_queue, sel_thread::read_fd, sel_thread_destroy(), sel_thread_handler(), sel_thread::spipe, sel_thread::stop_flag, sel_thread::thread_id, work_destroy(), sel_thread::work_destroy, work_handler(), sel_thread::work_handler, and sel_thread::write_fd.
Referenced by iochan_man_events(), test_create_destroy(), and test_for_real_work().
void sel_thread_destroy | ( | sel_thread_t | p | ) |
destorys select thread
p | select thread handler |
Definition at line 182 of file sel_thread.c.
References sel_thread::input_data, sel_thread::input_queue, sel_thread::mutex, sel_thread::nmem, sel_thread::no_threads, sel_thread::output_queue, queue_trav(), sel_thread::spipe, sel_thread::stop_flag, sel_thread::thread_id, and sel_thread::work_destroy.
Referenced by iochan_man_destroy(), sel_thread_create(), test_create_destroy(), and test_for_real_work().
|
static |
Definition at line 83 of file sel_thread.c.
References work_item::data, sel_thread::input_data, sel_thread::input_queue, input_queue_length, sel_thread::mutex, work_item::next, sel_thread::output_queue, queue_remove_last(), sel_thread::stop_flag, sel_thread::work_handler, and sel_thread::write_fd.
Referenced by sel_thread_create().
void* sel_thread_result | ( | sel_thread_t | p | ) |
gets result of work
p | select thread handler |
Definition at line 230 of file sel_thread.c.
References work_item::data, sel_thread::free_queue, sel_thread::mutex, work_item::next, sel_thread::output_queue, queue_remove_last(), and sel_thread::read_fd.
Referenced by event_loop(), and iochan_handler().
|
static |
Definition at line 81 of file sel_thread.c.
Referenced by sel_thread_add(), and sel_thread_handler().