WaitObjects.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2006-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: Urs Helmig
  6. //-----------------------------------------------------------------------------
  7. /*!
  8. \file
  9. \brief Declaration of WaitObjects class
  10. */
  11. #ifndef __WAITOBJECTS_H__
  12. #define __WAITOBJECTS_H__
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif // _MSC_VER > 1000
  16. #include <pylon/Platform.h>
  17. #ifdef _MSC_VER
  18. # pragma pack(push, PYLON_PACKING)
  19. #endif /* _MSC_VER */
  20. #include <pylon/WaitObject.h>
  21. namespace Pylon
  22. {
  23. class WaitObject;
  24. enum EWaitExResult;
  25. namespace PylonPrivate
  26. {
  27. struct WaitObjectsImpl;
  28. }
  29. // -------------------------------------------------------------------------
  30. // class WaitObjects
  31. // ----------------------------------------------------------------------
  32. /*!
  33. \brief A set of wait objects
  34. \ingroup PYLON_PUBLIC
  35. */
  36. // ----------------------------------------------------------------------
  37. class PYLONBASE_API WaitObjects
  38. {
  39. public:
  40. /// Creates an empty wait object set
  41. WaitObjects();
  42. /// destructor
  43. ~WaitObjects();
  44. /// copy constructor
  45. WaitObjects( const WaitObjects& );
  46. /// assignment operator
  47. WaitObjects& operator=( const WaitObjects& );
  48. public:
  49. /// Add an object to wait on and return the index of the added object
  50. /*!
  51. Calling Add from another thread during wait operations will cause undefined behaviour.
  52. */
  53. unsigned Add( const WaitObject& o );
  54. /// Removes all added wait objects
  55. /*!
  56. Calling RemoveAll from another thread during wait operations will cause undefined behaviour.
  57. */
  58. void RemoveAll( void );
  59. /// Wait for all objects to get signaled
  60. /*!
  61. \param timeout maximum wait period in milliseconds
  62. \return true if all objects were signaled
  63. */
  64. bool WaitForAll( unsigned timeout ) const;
  65. /// Wait for any one object to get signaled
  66. /*!
  67. \param timeout maximum wait period in milliseconds
  68. \param *pIndex (optional) pointer to buffer taking the index of
  69. the signaled object
  70. \return true if any object was signaled.
  71. */
  72. bool WaitForAny( unsigned timeout, unsigned* pIndex = NULL ) const;
  73. /// Wait for all objects to get signaled
  74. /*!
  75. \param bAlertable If true, the wait operation can be interrupted (Windows: APC; UNIX: signal)
  76. \param timeout maximum wait period in milliseconds
  77. */
  78. EWaitExResult WaitForAllEx( unsigned timeout, bool bAlertable ) const;
  79. /// Wait for any one object to get signaled
  80. /*!
  81. \param timeout maximum wait period in milliseconds
  82. \param bAlertable If true, the wait operation can be interrupted (Windows: APC; UNIX: signal)
  83. \param *pIndex (optional) pointer to buffer taking the index of
  84. the signaled object
  85. */
  86. EWaitExResult WaitForAnyEx( unsigned timeout, bool bAlertable, unsigned* pIndex = NULL ) const;
  87. private:
  88. PylonPrivate::WaitObjectsImpl* m_pImpl;
  89. };
  90. }
  91. #ifdef _MSC_VER
  92. # pragma pack(pop)
  93. #endif /* _MSC_VER */
  94. #endif //__WAITOBJECTS_H__