Imported Upstream version 3.1.0
[debian/amanda] / device-src / device-queueing.h
1 /*
2  * Copyright (c) 2008,2009 Zmanda, Inc.  All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 as published
6  * by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16  *
17  * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
18  * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
19  */
20
21 #ifndef DEVICE_QUEUEING_H
22 #define DEVICE_QUEUEING_H
23
24 /* some utilities for using queueing with device */
25
26 #include "queueing.h"
27
28 /* These functions will call device_read_block and device_write_block
29  * respectively. The user data should be a Device*.
30  *
31  * device_write_consumer assumes that the block_size passed to
32  * do_consumer_producer_queue_full is at least device->block_size();
33  * do_consumer_thread() will not pass a buffer of less than block_size
34  * to the consumer unless it has received EOF from the producer thread.
35  *
36  * Similarly, device_read_producer works similarly, but will expand its
37  * buffers if the device encounters larger blocks - this is Amanda's
38  * ability to read volumes written with larger block sizes.
39  */
40 producer_result_t device_read_producer(gpointer device,
41                                        queue_buffer_t *buffer,
42                                        size_t hint_size);
43 ssize_t device_write_consumer(gpointer device, queue_buffer_t *buffer);
44
45 #endif /* DEVICE_QUEUEING_H */