pipe.h 731 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2006-2021, 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. /**
  12. * Pipe Device
  13. */
  14. #include <rtthread.h>
  15. #include <rtdevice.h>
  16. struct rt_pipe_device
  17. {
  18. struct rt_device parent;
  19. rt_bool_t is_named;
  20. /* ring buffer in pipe device */
  21. struct rt_ringbuffer *fifo;
  22. rt_uint16_t bufsz;
  23. rt_uint8_t readers;
  24. rt_uint8_t writers;
  25. rt_wqueue_t reader_queue;
  26. rt_wqueue_t writer_queue;
  27. struct rt_mutex lock;
  28. };
  29. typedef struct rt_pipe_device rt_pipe_t;
  30. rt_pipe_t *rt_pipe_create(const char *name, int bufsz);
  31. int rt_pipe_delete(const char *name);
  32. #endif /* PIPE_H__ */