Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ug_thread_safe_counter.cc « threading « generic « UG « TranslationModel « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b4565f99d2bd3966a5e82f7e8a60cb52a3faea81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#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--;
  }


}