8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-30 22:43:03 +01:00
firebird-mirror/src/jrd/tpc_proto.h

103 lines
2.7 KiB
C
Raw Normal View History

2001-05-23 15:26:42 +02:00
/*
* PROGRAM: JRD Access method
* MODULE: tpc_proto.h
* DESCRIPTION: Prototype Header file for tpc.cpp
2001-05-23 15:26:42 +02:00
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef JRD_TPC_PROTO_H
#define JRD_TPC_PROTO_H
2001-05-23 15:26:42 +02:00
2011-05-09 12:15:19 +02:00
#include "../common/classes/array.h"
#include "../common/classes/SyncObject.h"
2001-05-23 15:26:42 +02:00
2011-05-09 12:15:19 +02:00
namespace Ods {
struct tx_inv_page;
};
namespace Jrd {
class Database;
class thread_db;
class TipCache
{
public:
2011-06-24 08:34:16 +02:00
explicit TipCache(Database* dbb);
2011-05-09 12:15:19 +02:00
~TipCache();
2011-05-11 03:18:28 +02:00
int cacheState(thread_db*, SLONG number);
void initializeTpc(thread_db*, SLONG number);
void setState(SLONG number, SSHORT state);
2011-05-11 03:18:28 +02:00
int snapshotState(thread_db*, SLONG number);
void updateCache(const Ods::tx_inv_page* tip_page, SLONG sequence);
2011-05-09 12:15:19 +02:00
private:
class TxPage : public pool_alloc_rpt<SCHAR, type_tpc>
{
public:
2011-05-11 03:18:28 +02:00
SLONG tpc_base; // id of first transaction in this block
UCHAR tpc_transactions[1]; // two bits per transaction
2011-05-09 12:15:19 +02:00
2011-05-10 03:12:14 +02:00
static const SLONG generate(const void*, const TxPage* item)
2011-05-11 03:18:28 +02:00
{
return item->tpc_base;
}
2011-05-09 12:15:19 +02:00
};
TxPage* allocTxPage(SLONG base);
2011-05-09 12:15:19 +02:00
SLONG cacheTransactions(thread_db* tdbb, SLONG oldest);
int extendCache(thread_db* tdbb, SLONG number);
void clearCache();
2011-05-11 03:18:28 +02:00
Database* m_dbb;
Firebird::SyncObject m_sync;
2011-05-09 12:15:19 +02:00
Firebird::SortedArray<TxPage*, Firebird::EmptyStorage<TxPage*>, SLONG, TxPage> m_cache;
};
inline int TPC_cache_state(thread_db* tdbb, SLONG number)
{
2011-05-11 03:18:28 +02:00
return tdbb->getDatabase()->dbb_tip_cache->cacheState(tdbb, number);
2011-05-09 12:15:19 +02:00
}
inline void TPC_initialize_tpc(thread_db* tdbb, SLONG number)
{
2011-05-11 03:18:28 +02:00
tdbb->getDatabase()->dbb_tip_cache->initializeTpc(tdbb, number);
2011-05-09 12:15:19 +02:00
}
inline void TPC_set_state(thread_db* tdbb, SLONG number, SSHORT state)
{
tdbb->getDatabase()->dbb_tip_cache->setState(number, state);
2011-05-09 12:15:19 +02:00
}
inline int TPC_snapshot_state(thread_db* tdbb, SLONG number)
{
2011-05-11 03:18:28 +02:00
return tdbb->getDatabase()->dbb_tip_cache->snapshotState(tdbb, number);
2011-05-09 12:15:19 +02:00
}
inline void TPC_update_cache(thread_db* tdbb, const Ods::tx_inv_page* tip_page, SLONG sequence)
{
tdbb->getDatabase()->dbb_tip_cache->updateCache(tip_page, sequence);
2011-05-09 12:15:19 +02:00
}
} // namespace Jrd
2011-05-11 03:18:28 +02:00
#endif // JRD_TPC_PROTO_H