1
0

pipe.h 768 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. */
  9. #ifndef PIPE_H__
  10. #define PIPE_H__
  11. #include <rtthread.h>
  12. /**
  13. * Pipe Device
  14. */
  15. struct rt_pipe_device
  16. {
  17. struct rt_device parent;
  18. rt_bool_t is_named;
  19. #ifdef RT_USING_POSIX_DEVIO
  20. int pipeno; /* for unamed pipe */
  21. #endif
  22. /* ring buffer in pipe device */
  23. struct rt_ringbuffer *fifo;
  24. rt_uint16_t bufsz;
  25. rt_wqueue_t reader_queue;
  26. rt_wqueue_t writer_queue;
  27. int writer;
  28. int reader;
  29. struct rt_mutex lock;
  30. };
  31. typedef struct rt_pipe_device rt_pipe_t;
  32. rt_pipe_t *rt_pipe_create(const char *name, int bufsz);
  33. int rt_pipe_delete(const char *name);
  34. #endif /* PIPE_H__ */