add doxygen via opencode

This commit is contained in:
2026-02-27 23:42:09 +03:00
parent 1739836a18
commit b53ef184dc
63 changed files with 3374 additions and 681 deletions

View File

@@ -1,9 +1,12 @@
/*! \file piblockingqueue.h
* \ingroup Thread
* \~\brief
* \~english Queue with blocking
* \~russian Блокирующая очередь
*/
//! \file piblockingqueue.h
//! \ingroup Thread
//! \brief
//! \~english Queue with blocking
//! \~russian Блокирующая очередь
//!
//! \details
//! \~english Thread-safe queue that supports blocking operations - waits for space when storing and waits for element when retrieving.
//! \~russian Потокобезопасная очередь с поддержкой блокирующих операций - ожидает место при добавлении и ожидает элемент при получении.
/*
PIP - Platform Independent Primitives
@@ -33,12 +36,13 @@
* \brief A Queue that supports operations that wait for the queue to become non-empty when retrieving an element, and
* wait for space to become available in the queue when storing an element.
*/
//! \~english Thread-safe blocking queue template class
//! \~russian Шаблонный класс потокобезопасной блокирующей очереди
template<typename T>
class PIBlockingQueue: private PIQueue<T> {
public:
/**
* \brief Constructor
*/
//! \~english Constructs queue with specified capacity
//! \~russian Создает очередь с указанной емкостью
explicit inline PIBlockingQueue(size_t capacity = SIZE_MAX,
PIConditionVariable * cond_var_add = new PIConditionVariable(),
PIConditionVariable * cond_var_rem = new PIConditionVariable())
@@ -46,9 +50,8 @@ public:
, cond_var_rem(cond_var_rem)
, max_size(capacity) {}
/**
* \brief Copy constructor. Initialize queue with copy of other queue elements. Not thread-safe for other queue.
*/
//! \~english Copy constructor from PIDeque
//! \~russian Конструктор копирования из PIDeque
explicit inline PIBlockingQueue(const PIDeque<T> & other)
: cond_var_add(new PIConditionVariable())
, cond_var_rem(new PIConditionVariable()) {
@@ -58,9 +61,8 @@ public:
mutex.unlock();
}
/**
* \brief Thread-safe copy constructor. Initialize queue with copy of other queue elements.
*/
//! \~english Thread-safe copy constructor from another PIBlockingQueue
//! \~russian Потокобезопасный конструктор копирования из другой PIBlockingQueue
inline PIBlockingQueue(PIBlockingQueue<T> & other): cond_var_add(new PIConditionVariable()), cond_var_rem(new PIConditionVariable()) {
other.mutex.lock();
mutex.lock();
@@ -75,11 +77,8 @@ public:
delete cond_var_rem;
}
/**
* \brief Inserts the specified element into this queue, waiting if necessary for space to become available.
*
* @param v the element to add
*/
//! \~english Inserts element waiting for space to become available
//! \~russian Вставляет элемент, ожидая освобождения места
PIBlockingQueue<T> & put(const T & v) {
mutex.lock();
cond_var_rem->wait(mutex, [&]() { return PIDeque<T>::size() < max_size; });
@@ -91,14 +90,8 @@ public:
PIBlockingQueue<T> & enqueue(const T & v) { return put(v); }
/**
* \brief Inserts the specified element at the end of this queue if it is possible to do so immediately without
* exceeding the queue's capacity, returning true upon success and false if this queue is full.
*
* @param v the element to add
* @param timeout the timeout waiting for inserting if que is full, if timeout is null, then returns immediately
* @return true if the element was added to this queue, else false
*/
//! \~english Inserts element if possible without exceeding capacity
//! \~russian Вставляет элемент если возможно без превышения емкости
bool offer(const T & v, PISystemTime timeout = {}) {
bool isOk;
mutex.lock();
@@ -129,16 +122,8 @@ public:
T dequeue() { return take(); }
/**
* \brief Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an
* element to become available.
*
* @param timeout how long to wait before giving up
* @param defaultVal value, which returns if the specified waiting time elapses before an element is available
* @param isOk flag, which indicates result of method execution. It will be set to false if timeout, or true if
* return value is retrieved value
* @return the head of this queue, or defaultVal if the specified waiting time elapses before an element is available
*/
//! \~english Retrieves and removes head, waiting until element becomes available
//! \~russian Извлекает и удаляет голову очереди, ожидая появления элемента
T poll(PISystemTime timeout = {}, const T & defaultVal = T(), bool * isOk = nullptr) {
T t = defaultVal;
bool isNotEmpty;
@@ -154,12 +139,8 @@ public:
return t;
}
/**
* \brief Returns the number of elements that this queue can ideally (in the absence of memory or resource
* constraints) contains. This is always equal to the initial capacity of this queue less the current size of this queue.
*
* @return the capacity
*/
//! \~english Returns queue capacity
//! \~russian Возвращает емкость очереди
size_t capacity() {
size_t c;
mutex.lock();
@@ -168,12 +149,8 @@ public:
return c;
}
/**
* \brief Returns the number of additional elements that this queue can ideally (in the absence of memory or resource
* constraints) accept. This is always equal to the initial capacity of this queue less the current size of this queue.
*
* @return the remaining capacity
*/
//! \~english Returns remaining capacity
//! \~russian Возвращает оставшуюся емкость
size_t remainingCapacity() {
mutex.lock();
size_t c = max_size - PIDeque<T>::size();
@@ -181,9 +158,8 @@ public:
return c;
}
/**
* \brief Returns the number of elements in this collection.
*/
//! \~english Returns number of elements in queue
//! \~russian Возвращает количество элементов в очереди
size_t size() {
mutex.lock();
size_t s = PIDeque<T>::size();
@@ -191,9 +167,8 @@ public:
return s;
}
/**
* \brief Removes all available elements from this queue and adds them to other given queue.
*/
//! \~english Removes all available elements and adds them to another queue
//! \~russian Удаляет все доступные элементы и добавляет их в другую очередь
size_t drainTo(PIDeque<T> & other, size_t maxCount = SIZE_MAX) {
mutex.lock();
size_t count = ((maxCount > PIDeque<T>::size()) ? PIDeque<T>::size() : maxCount);
@@ -203,9 +178,8 @@ public:
return count;
}
/**
* \brief Removes all available elements from this queue and adds them to other given queue.
*/
//! \~english Removes all available elements and adds them to another blocking queue
//! \~russian Удаляет все доступные элементы и добавляет их в другую блокирующую очередь
size_t drainTo(PIBlockingQueue<T> & other, size_t maxCount = SIZE_MAX) {
mutex.lock();
other.mutex.lock();