interprocess_sync_null.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (C) 2012 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. #ifndef __INTERPROCESS_SYNC_NULL_H__
  15. #define __INTERPROCESS_SYNC_NULL_H__
  16. #include "util/interprocess_sync.h"
  17. namespace isc {
  18. namespace util {
  19. /// \brief Null Interprocess Sync Class
  20. ///
  21. /// This class specifies a concrete implementation for a null (no effect)
  22. /// interprocess synchronization mechanism. Please see the
  23. /// InterprocessSync class documentation for usage.
  24. class InterprocessSyncNull : public InterprocessSync {
  25. public:
  26. /// \brief Constructor
  27. ///
  28. /// Creates a null interprocess synchronization object
  29. ///
  30. /// \param name Name of the synchronization task. This has to be
  31. /// identical among the various processes that need to be
  32. /// synchronized for the same task.
  33. InterprocessSyncNull(const std::string& task_name) :
  34. InterprocessSync(task_name)
  35. {}
  36. /// \brief Destructor
  37. virtual ~InterprocessSyncNull();
  38. protected:
  39. /// \brief Acquire the lock (never blocks)
  40. ///
  41. /// \return Always returns true
  42. bool lock();
  43. /// \brief Try to acquire a lock (doesn't block)
  44. ///
  45. /// \return Always returns true
  46. bool tryLock();
  47. /// \brief Release the lock
  48. ///
  49. /// \return Always returns true
  50. bool unlock();
  51. };
  52. } // namespace util
  53. } // namespace isc
  54. #endif // __INTERPROCESS_SYNC_NULL_H__