once.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef BOOST_THREAD_ONCE_HPP
  2. #define BOOST_THREAD_ONCE_HPP
  3. // once.hpp
  4. //
  5. // (C) Copyright 2006-7 Anthony Williams
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See
  8. // accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #include <boost/thread/detail/config.hpp>
  11. #ifdef BOOST_MSVC
  12. # pragma warning(push)
  13. # pragma warning(disable: 4702) // unreachable code
  14. #endif
  15. #include <boost/thread/detail/platform.hpp>
  16. #if defined(BOOST_THREAD_PLATFORM_WIN32)
  17. #include <boost/thread/win32/once.hpp>
  18. #elif defined(BOOST_THREAD_PLATFORM_PTHREAD)
  19. #if defined BOOST_THREAD_ONCE_FAST_EPOCH
  20. #include <boost/thread/pthread/once.hpp>
  21. #elif defined BOOST_THREAD_ONCE_ATOMIC
  22. #include <boost/thread/pthread/once_atomic.hpp>
  23. #else
  24. #error "Once Not Implemented"
  25. #endif
  26. #else
  27. #error "Boost threads unavailable on this platform"
  28. #endif
  29. #include <boost/config/abi_prefix.hpp>
  30. namespace boost
  31. {
  32. // template<class Callable, class ...Args> void
  33. // call_once(once_flag& flag, Callable&& func, Args&&... args);
  34. template<typename Function>
  35. inline void call_once(Function func,once_flag& flag)
  36. //inline void call_once(void (*func)(),once_flag& flag)
  37. {
  38. call_once(flag,func);
  39. }
  40. }
  41. #include <boost/config/abi_suffix.hpp>
  42. #ifdef BOOST_MSVC
  43. # pragma warning(pop)
  44. #endif
  45. #endif