~percona-dev/percona-xtradb-cluster/galera-2.x

« back to all changes in this revision

Viewing changes to gcache/src/pasture/Mutex.hpp

  • Committer: Alex Yurchenko
  • Date: 2011-08-31 13:30:55 UTC
  • Revision ID: ayurchen@void-20110831133055-6t4oc4zjfvq07e8t
Synced with SVN branch 1.x r2335

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2009 Codership Oy <info@codership.com>
 
3
 *
 
4
 */
 
5
 
 
6
#ifndef __GCACHE_MUTEX__
 
7
#define __GCACHE_MUTEX__
 
8
 
 
9
#include <pthread.h>
 
10
#include <cerrno>
 
11
 
 
12
#include "Exception.hpp"
 
13
#include <galerautils.hpp>
 
14
 
 
15
namespace gcache
 
16
{
 
17
    class Mutex
 
18
    {
 
19
 
 
20
        friend class Lock;
 
21
 
 
22
    protected:
 
23
 
 
24
        pthread_mutex_t value;
 
25
 
 
26
    public:
 
27
 
 
28
        Mutex ()
 
29
        {
 
30
            pthread_mutex_init (&value, NULL);
 
31
        };
 
32
 
 
33
        virtual ~Mutex ()
 
34
        {
 
35
            int err = pthread_mutex_destroy (&value);
 
36
            if (err != 0) {
 
37
                throw Exception (strerror(err), err);
 
38
            }
 
39
            log_debug << "Destroyed mutex " << &value;
 
40
        };
 
41
    };
 
42
}
 
43
 
 
44
#endif /* __GCACHE_MUTEX__ */