//
-// Open Service Platform
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
/**
* @class SemaphoreGuard
-* @brief This class is the RAII style class for %Semaphore class.
+* @brief This class is the RAII style class for the %Semaphore class.
*
* @since 2.0
*/
{
public:
/**
- * This constructor acquires a semaphore count in a blocking way.
- *
- * @since 2.0
- *
- * @param[in] s The %Semaphore instance to be manipulated
- * @remarks The specific error code can be accessed using the GetLastResult() method.
- * @see Semaphore::Acquire() for detailed exceptions
- */
+ * This constructor acquires a semaphore count in a blocking way.
+ *
+ * @since 2.0
+ *
+ * @param[in] s A Semaphore instance to manipulate
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see Semaphore::Acquire() for detailed exceptions
+ */
SemaphoreGuard(Semaphore& s)
: __s(s)
, __acquired(false)
}
/**
- * This constructor acquires a semaphore count in a non-blocking way.
- *
- * @since 2.0
- *
- * @param[in] s The %Semaphore instance to be manipulated
- * @remarks The specific error code can be accessed using the GetLastResult() method.
- * @see Semaphore::TryToAcquire() for detailed exceptions
- */
+ * This constructor acquires a semaphore count in a non-blocking way.
+ *
+ * @since 2.0
+ *
+ * @param[in] s A Semaphore instance to manipulate
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see Semaphore::TryToAcquire() for detailed exceptions
+ */
SemaphoreGuard(Semaphore& s, TryTag)
: __s(s)
, __acquired(false)
}
/**
- * This destructor releases the acquired semaphore count when going out of a scope
- *
- * @since 2.0
- *
- * @remarks The specific error code can be accessed using the GetLastResult() method.
- * @see Semaphore::Release() for detailed exceptions
- */
+ * This destructor releases the acquired semaphore count when going out of the scope
+ *
+ * @since 2.0
+ *
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see Semaphore::Release() for detailed exceptions
+ */
~SemaphoreGuard(void)
{
SetLastResult(Release());
}
/**
- * Returns whether this instance owns a semaphore count on the given semaphore at constructor.
- *
- * @since 2.0
- *
- * @return true if a semaphore is owned, @n
- * false otherwise.
- */
+ * Checks whether this instance owns a semaphore count on the given semaphore at constructor.
+ *
+ * @since 2.0
+ *
+ * @return @c true if a semaphore is owned, @n
+ * else @c false
+ */
bool IsAcquired(void) const
{
return __acquired;
}
/**
- * Returns whether this instance owns a semaphore count on the given semaphore at constructor. @n
- * Have same effects to calling IsAcquired().
- *
- * @since 2.0
- */
+ * Checks whether this instance owns a semaphore count on the given semaphore at constructor. @n
+ * Has the same effects as calling IsAcquired().
+ *
+ * @since 2.0
+ */
operator bool() const
{
return IsAcquired();
}
/**
- * Acquires a semaphore count manually on the given semaphore at constructor in a blocking way
- *
- * @since 2.0
- *
- * @return An error code.
- * @see Semaphore::Acquire() for detailed exceptions
- */
+ * Acquires a semaphore count manually on the given semaphore at constructor in a blocking way.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @see Semaphore::Acquire() for detailed exceptions
+ */
result Acquire(void)
{
return SetAcquiredAndReturn(__s.Acquire());
}
/**
- * Acquires a semaphore count manually on the given semaphore at constructor in a non-blocking way
- *
- * @since 2.0
- *
- * @return An error code.
- * @see Semaphore::TryToAcquire() for detailed exceptions
- */
+ * Acquires a semaphore count manually on the given semaphore at constructor in a non-blocking way.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @see Semaphore::TryToAcquire() for detailed exceptions
+ */
result TryToAcquire(void)
{
return SetAcquiredAndReturn(__s.TryToAcquire());
}
/**
- * Releases the acquired semaphore count manually
- *
- * @since 2.0
- *
- * @return An error code.
- * @see Semaphore::Release() for detailed exceptions
- */
+ * Releases the acquired semaphore count manually
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @see Semaphore::Release() for detailed exceptions
+ */
result Release(void)
{
result r = E_SUCCESS;