Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1b1576b657cc76ae7f476bb4d6c566b0aa5c6740 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*******************************************************************************
 * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Eclipse Distribution License v1.0 which accompany this distribution.
 * The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 * You may elect to redistribute this code under either of these licenses.
 *
 * Contributors:
 *     Wind River Systems - initial API and implementation
 *******************************************************************************/

/*
 * Utility module that implements an abstarct output queue.
 */

#ifndef D_outputbuf
#define D_outputbuf

#include <tcf/config.h>
#include <tcf/framework/link.h>

typedef struct OutputQueue OutputQueue;
typedef struct OutputBuffer OutputBuffer;

struct OutputQueue {
    int error;
    LINK queue;
    LINK pool;
    int pool_size;
    void (*post_io_request)(OutputBuffer *);
};

struct OutputBuffer {
    LINK link;
    OutputQueue * queue;
    char buf[128 * MEM_USAGE_FACTOR];
    size_t buf_len;
    size_t buf_pos;
};

#define output_queue_is_empty(q) (list_is_empty(&(q)->queue))

extern void output_queue_ini(OutputQueue * q);
extern void output_queue_add(OutputQueue * q, const void * buf, size_t size);
extern void output_queue_done(OutputQueue * q, int error, int size);
extern void output_queue_clear(OutputQueue * q);

#endif /* D_outputbuf */

Back to the top