~brianaker/libmemcached/gear-clean

« back to all changes in this revision

Viewing changes to libtest/thread.hpp

  • Committer: Brian Aker
  • Date: 2013-01-24 11:17:17 UTC
  • mto: This revision was merged to the branch mainline in revision 1144.
  • Revision ID: brian@tangent.org-20130124111717-nmiq5yf0v1ov9jhk
Correct style, use of newer YATL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
class Mutex
47
47
{
48
48
public:
49
 
  Mutex()
 
49
  Mutex() :
 
50
    _err(0)
50
51
  {
51
 
    int err;
52
 
    if ((err= pthread_mutex_init(&_mutex, NULL)))
53
 
    {
54
 
      throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "pthread_mutex_init: %s", strerror(err));
55
 
    }
 
52
    _err= pthread_mutex_init(&_mutex, NULL);
56
53
  }
57
54
 
58
55
  ~Mutex()
59
56
  {
60
 
    int err;
61
 
    if ((err= pthread_mutex_destroy(&_mutex)))
 
57
    if ((_err= pthread_mutex_destroy(&_mutex)))
62
58
    {
63
 
      throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "pthread_cond_destroy: %s", strerror(err));
 
59
      throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "pthread_cond_destroy: %s", strerror(_err));
64
60
    }
65
61
  }
66
62
 
67
63
  pthread_mutex_t* handle()
68
64
  {
 
65
    if (_err != 0)
 
66
    {
 
67
      throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "pthread_mutex_init: %s", strerror(_err));
 
68
    }
 
69
 
69
70
    return &_mutex;
70
71
  }
71
72
 
72
73
private:
 
74
  int _err;
73
75
  pthread_mutex_t _mutex;
74
76
};
75
77