1
/* Copyright (C) 2009 Sun Microsystems, Inc.
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#if !defined(TRANSACTION_STATE_H)
17
#define TRANSACTION_STATE_H
20
#include "SyncObject.h"
30
// The following are 'relative states'. See getRelativeState()
33
CommittedVisible, // 5
34
CommittedInvisible, // 6
38
// And the remaining are for transactions pending reuse
45
// TransactionState stores the main state information for a Transaction.
46
// The reason for having this as a separate class instead of having it
47
// stored in the Transaction object is that we want to be able to purge
48
// transaction objects earlier than when record versions are scavanged.
49
// To be able to do that we let the TransactionState object live as long
50
// as there is RecordVersions refering to it while we purge the Transaction
53
class TransactionState
60
void waitForTransaction();
61
bool committedBefore(TransId transactionId);
63
inline bool isActive()
65
return state == Active || state == Limbo;
68
inline bool isCommitted()
70
return state == Committed;
75
TransId transactionId; // used also as startEvent by dep.mgr.
76
TransId commitId; // used as commitEvent by dep.mgr.
77
volatile INTERLOCK_TYPE state;
78
SyncObject syncIsActive;
79
bool pendingPageWrites;
80
bool hasTransactionReference;
82
volatile TransactionState* waitingFor; // Used for deadlock detection
85
volatile INTERLOCK_TYPE useCount;