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.

63 lines
2.2 KiB

  1. /*
  2. Copyright 2005-2014 Intel Corporation. All Rights Reserved.
  3. This file is part of Threading Building Blocks.
  4. Threading Building Blocks is free software; you can redistribute it
  5. and/or modify it under the terms of the GNU General Public License
  6. version 2 as published by the Free Software Foundation.
  7. Threading Building Blocks is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  9. of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with Threading Building Blocks; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  14. As a special exception, you may use this file as part of a free software
  15. library without restriction. Specifically, if other files instantiate
  16. templates or use macros or inline functions from this file, or you compile
  17. this file and link it with other files to produce an executable, this
  18. file does not by itself cause the resulting executable to be covered by
  19. the GNU General Public License. This exception does not however
  20. invalidate any other reasons why the executable file might be covered by
  21. the GNU General Public License.
  22. */
  23. #ifndef __TBB_null_mutex_H
  24. #define __TBB_null_mutex_H
  25. namespace tbb {
  26. //! A mutex which does nothing
  27. /** A null_mutex does no operation and simulates success.
  28. @ingroup synchronization */
  29. class null_mutex {
  30. //! Deny assignment and copy construction
  31. null_mutex( const null_mutex& );
  32. void operator=( const null_mutex& );
  33. public:
  34. //! Represents acquisition of a mutex.
  35. class scoped_lock {
  36. public:
  37. scoped_lock() {}
  38. scoped_lock( null_mutex& ) {}
  39. ~scoped_lock() {}
  40. void acquire( null_mutex& ) {}
  41. bool try_acquire( null_mutex& ) { return true; }
  42. void release() {}
  43. };
  44. null_mutex() {}
  45. // Mutex traits
  46. static const bool is_rw_mutex = false;
  47. static const bool is_recursive_mutex = true;
  48. static const bool is_fair_mutex = true;
  49. };
  50. }
  51. #endif /* __TBB_null_mutex_H */