locks.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. /// This file (right now) provides dummy locks
  15. /// It also contains code to use boost/threads locks:
  16. ///
  17. ///
  18. /// All locks are dummy classes that don't actually do anything. At this moment,
  19. /// only the very minimal set of methods that we actually use is defined.
  20. ///
  21. /// Note that we need to include <config.h> in our .cc files for that
  22. /// to be set. we might want to enfore this at compile time with a check
  23. /// (TODO)
  24. #ifndef LOCKS
  25. #define LOCKS
  26. namespace isc {
  27. namespace util {
  28. namespace locks {
  29. class mutex {
  30. };
  31. class recursive_mutex {
  32. };
  33. class upgradable_mutex {
  34. };
  35. template <typename T>
  36. class sharable_lock {
  37. public:
  38. sharable_lock(T) {}
  39. };
  40. template <typename T>
  41. class scoped_lock {
  42. public:
  43. scoped_lock(T) {}
  44. // We need to define this explicitly. Some versions of clang++ would
  45. // complain about this otherwise. See Trac ticket #2340
  46. ~scoped_lock() {}
  47. void lock() {}
  48. void unlock() {}
  49. };
  50. } // namespace locks
  51. } // namespace util
  52. } // namespace isc
  53. #endif // LOCKS