mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 14:05:29 +03:00
49 lines
775 B
C++
49 lines
775 B
C++
#include "moses/TranslationModel/UG/generic/threading/ug_thread_safe_counter.h"
|
|
namespace Moses
|
|
{
|
|
ThreadSafeCounter::
|
|
ThreadSafeCounter()
|
|
: ctr(0)
|
|
{ }
|
|
|
|
size_t
|
|
ThreadSafeCounter::
|
|
operator++()
|
|
{
|
|
boost::lock_guard<boost::mutex> guard(this->lock);
|
|
return ++ctr;
|
|
}
|
|
|
|
size_t
|
|
ThreadSafeCounter::
|
|
operator++(int foo)
|
|
{
|
|
boost::lock_guard<boost::mutex> guard(this->lock);
|
|
return ctr++;
|
|
}
|
|
|
|
ThreadSafeCounter::
|
|
operator size_t() const
|
|
{
|
|
return ctr;
|
|
}
|
|
|
|
size_t
|
|
ThreadSafeCounter::
|
|
operator--()
|
|
{
|
|
boost::lock_guard<boost::mutex> guard(this->lock);
|
|
return --ctr;
|
|
}
|
|
|
|
size_t
|
|
ThreadSafeCounter::
|
|
operator--(int foo)
|
|
{
|
|
boost::lock_guard<boost::mutex> guard(this->lock);
|
|
return ctr--;
|
|
}
|
|
|
|
|
|
}
|