2 * Copyright (C) 2005-2007 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * @defgroup processor processor
19 * @{ @ingroup processing
25 typedef struct processor_t processor_t
;
30 #include <processing/jobs/job.h>
33 * The processor uses threads to process queued jobs.
38 * Get the total number of threads used by the processor.
40 * @return size of thread pool
42 u_int (*get_total_threads
) (processor_t
*this);
45 * Get the number of threads currently waiting.
47 * @return number of idle threads
49 u_int (*get_idle_threads
) (processor_t
*this);
52 * Get the number of queued jobs.
54 * @returns number of items in queue
56 u_int (*get_job_load
) (processor_t
*this);
59 * Adds a job to the queue.
61 * This function is non blocking and adds a job_t to the queue.
63 * @param job job to add to the queue
65 void (*queue_job
) (processor_t
*this, job_t
*job
);
68 * Set the number of threads to use in the processor.
70 * If the number of threads is smaller than number of currently running
71 * threads, thread count is decreased. Use 0 to disable the processor.
72 * This call blocks if it decreases thread count until threads have
73 * terminated, so make sure there are not too many blocking jobs.
75 * @param count number of threads to allocate
77 void (*set_threads
)(processor_t
*this, u_int count
);
80 * Destroy a processor object.
82 void (*destroy
) (processor_t
*processor
);
86 * Create the thread pool without any threads.
88 * Use the set_threads method to start processing jobs.
90 * @return processor_t object
92 processor_t
*processor_create();
94 #endif /** PROCESSOR_H_ @}*/