pipe.h 805 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2006-2018, 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. #ifndef RT_PIPE_BUFSZ
  17. #define PIPE_BUFSZ 512
  18. #else
  19. #define PIPE_BUFSZ RT_PIPE_BUFSZ
  20. #endif
  21. struct rt_pipe_device
  22. {
  23. struct rt_device parent;
  24. /* ring buffer in pipe device */
  25. struct rt_ringbuffer *fifo;
  26. rt_uint16_t bufsz;
  27. rt_uint8_t readers;
  28. rt_uint8_t writers;
  29. rt_wqueue_t reader_queue;
  30. rt_wqueue_t writer_queue;
  31. struct rt_mutex lock;
  32. };
  33. typedef struct rt_pipe_device rt_pipe_t;
  34. rt_pipe_t *rt_pipe_create(const char *name, int bufsz);
  35. int rt_pipe_delete(const char *name);
  36. #endif /* PIPE_H__ */