84 lines
3.3 KiB
C++
84 lines
3.3 KiB
C++
/*
|
||
PIP - Platform Independent Primitives
|
||
PISpinlock
|
||
Ivan Pelipenko peri4ko@yandex.ru
|
||
|
||
This program is free software: you can redistribute it and/or modify
|
||
it under the terms of the GNU Lesser General Public License as published by
|
||
the Free Software Foundation, either version 3 of the License, or
|
||
(at your option) any later version.
|
||
|
||
This program is distributed in the hope that it will be useful,
|
||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
GNU Lesser General Public License for more details.
|
||
|
||
You should have received a copy of the GNU Lesser General Public License
|
||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
*/
|
||
|
||
//! \addtogroup Thread
|
||
//! \{
|
||
//! \class PISpinlock pispinlock.h
|
||
//!
|
||
//! \~\brief
|
||
//! \~english Fast and full-load lock
|
||
//! \~russian Быстрая блокировка с полной нагрузкой
|
||
//!
|
||
//! \~\details
|
||
//! \~english
|
||
//! %PISpinlock provides critical code section defence between several threads.
|
||
//! %PISpinlock functionality similar to PIMutex, but working on atomic
|
||
//! type and \a lock() method wait with 100% CPU core load.
|
||
//!
|
||
//! For automatic lock-unlock use \a PISpinlockLocker.
|
||
//!
|
||
//! \~russian
|
||
//! %PISpinlock предоставляет межпотоковую защиту критических секций кода.
|
||
//! Функционально он аналогичен PIMutex, однако работает на атомарном типе
|
||
//! и ожидание разблокировки в методе \a lock() нагружает ядро ЦП на 100%.
|
||
//!
|
||
//! Для автоматической блокировки-разблокировки используйте \a PISpinlockLocker.
|
||
//!
|
||
//! \~\note
|
||
//! \~english
|
||
//! Use this type instead of PIMutex when less waiting time is more
|
||
//! important than CPU load!
|
||
//!
|
||
//! \~russian
|
||
//! Используйте этот класс вместо PIMutex когда время ожидания гораздо важнее
|
||
//! чем нагрузка на ЦП!
|
||
//!
|
||
//! \}
|
||
|
||
|
||
//! \addtogroup Thread
|
||
//! \{
|
||
//! \class PISpinlockLocker pispinlock.h
|
||
//!
|
||
//! \~\brief
|
||
//! \~english %PISpinlock autolocker
|
||
//! \~russian Автоблокировщик %PISpinlock
|
||
//!
|
||
//!
|
||
//! \~\details
|
||
//! \~english
|
||
//! When a %PISpinlockLocker object is created, it attempts to lock the spinlock it is given, if "condition" true.
|
||
//! When control leaves the scope in which the %PISpinlockLocker object was created,
|
||
//! the %PISpinlockLocker is destructed and the spinlock is released, if "condition" true.
|
||
//!
|
||
//! If "condition" false this class do nothing.
|
||
//!
|
||
//! The %PISpinlockLocker class is non-copyable.
|
||
//!
|
||
//! \~russian
|
||
//! При создании экземпляра %PISpinlockLocker блокируется переданный спинлок, если "condition" \c true.
|
||
//! Когда выполнение покидает область жизни объекта, вызывается его деструктор и спинлок
|
||
//! разблокируется, если "condition" был \c true.
|
||
//!
|
||
//! Если "condition" \c false, то этот объект ничего не делает.
|
||
//!
|
||
//! Класс %PISpinlockLocker некопируемый.
|
||
//!
|
||
//! \}
|