Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vcos_event.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. Copyright (c) 2012, Broadcom Europe Ltd
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. /*=============================================================================
  26. VideoCore OS Abstraction Layer - public header file for events
  27. =============================================================================*/
  28. #ifndef VCOS_EVENT_H
  29. #define VCOS_EVENT_H
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. #include "vcos_types.h"
  34. #include "pthreads/vcos_platform.h"
  35. /**
  36. * \file
  37. *
  38. * An event is akin to the Win32 auto-reset event.
  39. *
  40. *
  41. * Signalling an event will wake up one waiting thread only. Once one
  42. * thread has been woken the event atomically returns to the unsignalled
  43. * state.
  44. *
  45. * If no threads are waiting on the event when it is signalled it remains
  46. * signalled.
  47. *
  48. * This is almost, but not quite, completely unlike the "event flags"
  49. * object based on Nucleus event groups and ThreadX event flags.
  50. *
  51. * In particular, it should be similar in speed to a semaphore, unlike
  52. * the event flags.
  53. */
  54. /**
  55. * Create an event instance.
  56. *
  57. * @param event Filled in with constructed event.
  58. * @param name Name of the event (for debugging)
  59. *
  60. * @return VCOS_SUCCESS on success, or error code.
  61. */
  62. VCOS_INLINE_DECL
  63. VCOS_STATUS_T vcos_event_create(VCOS_EVENT_T *event, const char *name);
  64. #ifndef vcos_event_signal
  65. /**
  66. * Signal the event. The event will return to being unsignalled
  67. * after exactly one waiting thread has been woken up. If no
  68. * threads are waiting it remains signalled.
  69. *
  70. * @param event The event to signal
  71. */
  72. VCOS_INLINE_DECL
  73. void vcos_event_signal(VCOS_EVENT_T *event);
  74. /**
  75. * Wait for the event.
  76. *
  77. * @param event The event to wait for
  78. * @return VCOS_SUCCESS on success, VCOS_EAGAIN if the wait was interrupted.
  79. */
  80. VCOS_INLINE_DECL
  81. VCOS_STATUS_T vcos_event_wait(VCOS_EVENT_T *event);
  82. /**
  83. * Try event, but don't block.
  84. *
  85. * @param event The event to try
  86. * @return VCOS_SUCCESS on success, VCOS_EAGAIN if the event is not currently signalled
  87. */
  88. VCOS_INLINE_DECL
  89. VCOS_STATUS_T vcos_event_try(VCOS_EVENT_T *event);
  90. #endif
  91. /*
  92. * Destroy an event.
  93. */
  94. VCOS_INLINE_DECL
  95. void vcos_event_delete(VCOS_EVENT_T *event);
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif