~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/cslib/CSMutex.h

This patch completes the first step in the splitting of
the XA resource manager API from the storage engine API,
as outlined in the specification here:

http://drizzle.org/wiki/XaStorageEngine

* Splits plugin::StorageEngine into a base StorageEngine
  class and two derived classes, TransactionalStorageEngine
  and XaStorageEngine.  XaStorageEngine derives from
  TransactionalStorageEngine and creates the XA Resource
  Manager API for storage engines.

  - The methods moved from StorageEngine to TransactionalStorageEngine
    include releaseTemporaryLatches(), startConsistentSnapshot(), 
    commit(), rollback(), setSavepoint(), releaseSavepoint(),
    rollbackToSavepoint() and hasTwoPhaseCommit()
  - The methods moved from StorageEngine to XaStorageEngine
    include recover(), commitXid(), rollbackXid(), and prepare()

* Places all static "EngineVector"s into their proper
  namespaces (typedefs belong in header files, not implementation files)
  and places all static methods corresponding
  to either only transactional engines or only XA engines
  into their respective files in /drizzled/plugin/

* Modifies the InnoDB "handler" files to extend plugin::XaStorageEngine
  and not plugin::StorageEngine

The next step, as outlined in the wiki spec page above, is to isolate
the XA Resource Manager API into its own plugin class and modify
plugin::XaStorageEngine to implement plugin::XaResourceManager via
composition.  This is necessary to enable building plugins which can
participate in an XA transaction *without having to have that plugin
implement the entire storage engine API*

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
2
 
 *
3
 
 * PrimeBase Media Stream for MySQL
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
 
 *
19
 
 * Original author: Paul McCullagh (H&G2JCtL)
20
 
 * Continued development: Barry Leslie
21
 
 *
22
 
 * 2007-06-06
23
 
 *
24
 
 * CORE SYSTEM:
25
 
 * A basic mutex (mutual exclusion) object.
26
 
 *
27
 
 */
28
 
 
29
 
#ifndef __CSMUTEX_H__
30
 
#define __CSMUTEX_H__
31
 
 
32
 
#include <pthread.h>
33
 
 
34
 
#include "CSDefs.h"
35
 
 
36
 
class CSThread;
37
 
 
38
 
class CSMutex {
39
 
public:
40
 
        CSMutex();
41
 
        virtual ~CSMutex();
42
 
 
43
 
        virtual void lock();
44
 
        virtual void unlock();
45
 
 
46
 
        friend class CSLock;
47
 
        friend class CSSync;
48
 
 
49
 
private:
50
 
        pthread_mutex_t iMutex;
51
 
#ifdef DEBUG
52
 
        CSThread                *iLocker;
53
 
public:
54
 
        bool                    trace;
55
 
#endif
56
 
};
57
 
 
58
 
class CSLock : public CSMutex {
59
 
public:
60
 
        CSLock();
61
 
        virtual ~CSLock();
62
 
 
63
 
        virtual void lock();
64
 
        virtual void unlock();
65
 
        virtual bool haveLock();
66
 
 
67
 
        friend class CSSync;
68
 
 
69
 
private:
70
 
        CSThread                *iLockingThread;
71
 
        int                             iLockCount;
72
 
};
73
 
 
74
 
class CSSync : public CSLock {
75
 
public:
76
 
        CSSync();
77
 
        virtual ~CSSync();
78
 
        
79
 
        /* Wait for resources on the object
80
 
         * to be freed.
81
 
         *
82
 
         * This function may only be called
83
 
         * if the thread has already locked the
84
 
         * object.
85
 
         */
86
 
        virtual void wait();
87
 
 
88
 
        /* Wait for a certain amount of time, in
89
 
         * milli-seconds (1/1000th of a second).
90
 
         */
91
 
        void wait(time_t mill_sec);
92
 
 
93
 
        /*
94
 
         * Wakeup any waiters.
95
 
         */
96
 
        virtual void wakeup();
97
 
 
98
 
private:
99
 
        pthread_cond_t  iCondition;
100
 
};
101
 
 
102
 
#endif
103