aboutsummaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
Diffstat (limited to 'support')
-rw-r--r--support/Mutex.h12
-rw-r--r--support/ToolchainSupport.h26
2 files changed, 33 insertions, 5 deletions
diff --git a/support/Mutex.h b/support/Mutex.h
index 6d0a387678..d70dd7595b 100644
--- a/support/Mutex.h
+++ b/support/Mutex.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -29,6 +29,7 @@
namespace arm_compute
{
#ifndef NO_MULTI_THREADING
+/** Wrapper of Mutex data-object */
using Mutex = std::mutex;
#else /* NO_MULTI_THREADING */
/** Wrapper implementation of Mutex data-object */
@@ -36,13 +37,20 @@ class Mutex
{
public:
/** Default constructor */
- Mutex() = default;
+ Mutex() = default;
+ /** Default destructor */
~Mutex() = default;
+ /** Lock */
void lock() {};
+ /** Unlock */
void unlock() {};
+ /** Try the lock.
+ *
+ * @return true.
+ */
bool try_lock()
{
return true;
diff --git a/support/ToolchainSupport.h b/support/ToolchainSupport.h
index 56cbce8cc4..cb156f39c7 100644
--- a/support/ToolchainSupport.h
+++ b/support/ToolchainSupport.h
@@ -339,24 +339,37 @@ inline bool isfinite(half_float::half value)
namespace cpp14
{
/** make_unique is missing in CPP11. Re-implement it according to the standard proposal. */
+
+/**<Template for single object */
template <class T>
struct _Unique_if
{
- typedef std::unique_ptr<T> _Single_object;
+ typedef std::unique_ptr<T> _Single_object; /**< Single object type */
};
+/** Template for array */
template <class T>
struct _Unique_if<T[]>
{
- typedef std::unique_ptr<T[]> _Unknown_bound;
+ typedef std::unique_ptr<T[]> _Unknown_bound; /**< Array type */
};
+/** Template for array with known bounds (to throw an error).
+ *
+ * @note this is intended to never be hit.
+ */
template <class T, size_t N>
struct _Unique_if<T[N]>
{
- typedef void _Known_bound;
+ typedef void _Known_bound; /**< Should never be used */
};
+/** Construct a single object and return a unique pointer to it.
+ *
+ * @param[in] args Constructor arguments.
+ *
+ * @return a unique pointer to the new object.
+ */
template <class T, class... Args>
typename _Unique_if<T>::_Single_object
make_unique(Args &&... args)
@@ -364,6 +377,12 @@ make_unique(Args &&... args)
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
+/** Construct an array of objects and return a unique pointer to it.
+ *
+ * @param[in] n Array size
+ *
+ * @return a unique pointer to the new array.
+ */
template <class T>
typename _Unique_if<T>::_Unknown_bound
make_unique(size_t n)
@@ -372,6 +391,7 @@ make_unique(size_t n)
return std::unique_ptr<T>(new U[n]());
}
+/** It is invalid to attempt to make_unique an array with known bounds. */
template <class T, class... Args>
typename _Unique_if<T>::_Known_bound
make_unique(Args &&...) = delete;