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
19#pragma once
20
36
37#include <sys/types.h>
38
39#include "mutex.h"
40#include "ringbuffer.h"
41#include "thread.h"
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47#ifndef PIPE_BUF
48# define PIPE_BUF (128)
49#endif
50
63
71void pipe_init(pipe_t *pipe, ringbuffer_t *rb, void (*free)(void *));
72
85ssize_t pipe_read(pipe_t *pipe, void *buf, size_t n);
86
99ssize_t pipe_write(pipe_t *pipe, const void *buf, size_t n);
100
108pipe_t *pipe_malloc(unsigned size);
109
118
119#ifdef __cplusplus
120}
121#endif
122
struct _thread thread_t
forward declaration for thread_t, defined in thread.h
Definition sched.h:154
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.
Ringbuffer.
Definition ringbuffer.h:35
A generic pipe.
Definition pipe.h:54
thread_t * read_blocked
A thread that wants to write to this full pipe.
Definition pipe.h:56
ringbuffer_t * rb
Wrapped ringbuffer.
Definition pipe.h:55
void(* free)(void *)
Function to call by pipe_free().
Definition pipe.h:60
thread_t * write_blocked
A thread that wants to read from this empty pipe.
Definition pipe.h:58