Loading...
Searching...
No Matches
pipe.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014 René Kijewski <rene.kijewski@fu-berlin.de>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
35#ifndef PIPE_H
36#define PIPE_H
37
38#include <sys/types.h>
39
40#include "mutex.h"
41#include "ringbuffer.h"
42#include "thread.h"
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#ifndef PIPE_BUF
49# define PIPE_BUF (128)
50#endif
51
64
72void pipe_init(pipe_t *pipe, ringbuffer_t *rb, void (*free)(void *));
73
86ssize_t pipe_read(pipe_t *pipe, void *buf, size_t n);
87
100ssize_t pipe_write(pipe_t *pipe, const void *buf, size_t n);
101
109pipe_t *pipe_malloc(unsigned size);
110
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif /* PIPE_H */
void free(void *ptr)
This is a no-op.
pipe_t * pipe_malloc(unsigned size)
Dynamically allocate a pipe with room for size bytes.
ssize_t pipe_read(pipe_t *pipe, void *buf, size_t n)
Read from a pipe.
void pipe_free(pipe_t *rp)
Free a pipe.
struct riot_pipe pipe_t
A generic pipe.
ssize_t pipe_write(pipe_t *pipe, const void *buf, size_t n)
Write to a pipe.
void pipe_init(pipe_t *pipe, ringbuffer_t *rb, void(*free)(void *))
Initialize a pipe.
Mutex for thread synchronization.
A utility for storing and retrieving byte data using a ring buffer.
thread_t holds thread's context data.
Definition thread.h:168
Ringbuffer.
Definition ringbuffer.h:36
A generic pipe.
Definition pipe.h:55
thread_t * read_blocked
A thread that wants to write to this full pipe.
Definition pipe.h:57
ringbuffer_t * rb
Wrapped ringbuffer.
Definition pipe.h:56
void(* free)(void *)
Function to call by pipe_free().
Definition pipe.h:61
thread_t * write_blocked
A thread that wants to read from this empty pipe.
Definition pipe.h:59