thread.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // C++ wrapper for Pthreads-related features
  2. //
  3. // Platform: ISO C++ 98/11 - POSIX
  4. // $Id$
  5. //
  6. // (c) __vic 2007
  7. #ifndef __VIC_POSIX_THREAD_H
  8. #define __VIC_POSIX_THREAD_H
  9. #include<__vic/posix/_cfg.h>
  10. #include<__vic/defs.h>
  11. #include<pthread.h>
  12. #include<signal.h>
  13. namespace __vic { namespace posix {
  14. //////////////////////////////////////////////////////////////////////////////
  15. namespace this_thread
  16. {
  17. int sigwait(const ::sigset_t & );
  18. #ifdef __VIC_POSIX_RT__
  19. int sigwait_at_most(const ::sigset_t & , const ::timespec & );
  20. ::siginfo_t sigwaitinfo(const ::sigset_t & );
  21. bool sigwaitinfo_at_most(
  22. const ::sigset_t & , const ::timespec & , ::siginfo_t & );
  23. #endif
  24. void change_sigmask(int , const ::sigset_t & , ::sigset_t * = nullptr);
  25. inline void block_signals(const ::sigset_t &mask, ::sigset_t *oldmask = nullptr)
  26. {
  27. change_sigmask(SIG_BLOCK, mask, oldmask);
  28. }
  29. inline void unblock_signals(const ::sigset_t &mask, ::sigset_t *oldmask = nullptr)
  30. {
  31. change_sigmask(SIG_UNBLOCK, mask, oldmask);
  32. }
  33. inline void set_sigmask(const ::sigset_t &mask, ::sigset_t *oldmask = nullptr)
  34. {
  35. change_sigmask(SIG_SETMASK, mask, oldmask);
  36. }
  37. }
  38. //////////////////////////////////////////////////////////////////////////////
  39. }} // namespace
  40. #endif // header guard