Skip to content
Snippets Groups Projects
Commit a12ca3d0 authored by Gontier Antonin's avatar Gontier Antonin :fox:
Browse files

Ajout de la doc de SMP.h (doc non générée)

parent 961e5aa4
No related branches found
No related tags found
No related merge requests found
...@@ -21,26 +21,85 @@ ...@@ -21,26 +21,85 @@
#include <atomic> #include <atomic>
/**
* @namespace SMP
* @brief A Symmetric multiprocessing implementation
*
*/
namespace SMP { namespace SMP {
/**
* @fn get_num_cpus
* @brief Returns the number of hardware thread contexts. This value is supposed to be equals to the number of cores of the machine.
*
* @return The number of hardware thread contexts
*/
int get_num_cpus(); int get_num_cpus();
/**
* @class Mutex
* @brief Class used to protect data shared with different threads.
*
* @copyright GNU General Public License
* @copyright Part of Leela Zero software
* @author Gian-Carlo Pascutto
*/
class Mutex { class Mutex {
public: public:
/**
* @fn Mutex
* @brief Standard constructor (Set the Mutex as unlocked)
*
*/
Mutex(); Mutex();
/**
* @fn ~Mutex
* @brief Standard destructor
*
*/
~Mutex() = default; ~Mutex() = default;
friend class Lock; friend class Lock;
private: private:
std::atomic<bool> m_lock; std::atomic<bool> m_lock; /**< Boolean representing the locking state of the Mutex */
}; };
/**
* @class Lock
* @brief Class used to handle Mutex
*
* @copyright GNU General Public License
* @copyright Part of Leela Zero software
* @author Gian-Carlo Pascutto
*/
class Lock { class Lock {
public: public:
/**
* @fn Lock
* @brief Construct a Lock with a Mutex
*
* @param[in] m
*/
explicit Lock(Mutex & m); explicit Lock(Mutex & m);
/**
* @fn ~Lock
* @brief Standard destructor
*
*/
~Lock(); ~Lock();
/**
* @fn lock
* @brief Try to lock the Mutex
*
*/
void lock(); void lock();
/**
* @fn unlock
* @brief Unlock the Mutex
*
*/
void unlock(); void unlock();
private: private:
Mutex * m_mutex; Mutex * m_mutex; /**< The associated mutex*/
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment