2001-05-23 15:26:42 +02:00
|
|
|
//____________________________________________________________
|
|
|
|
//
|
|
|
|
// PROGRAM: Alice (All Else) Utility
|
|
|
|
// MODULE: all.cpp
|
|
|
|
// DESCRIPTION: Block allocator
|
|
|
|
//
|
|
|
|
// 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): ______________________________________.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//____________________________________________________________
|
|
|
|
//
|
2003-09-15 18:32:22 +02:00
|
|
|
// $Id: all.cpp,v 1.12 2003-09-15 16:25:49 brodsom Exp $
|
2001-05-23 15:26:42 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
#include "../alice/all.h"
|
2002-12-16 16:16:32 +01:00
|
|
|
#include "firebird.h"
|
2001-12-24 03:51:06 +01:00
|
|
|
//#include "../jrd/ib_stdio.h"
|
|
|
|
//#include "../jrd/common.h"
|
|
|
|
//#include "../jrd/ibsetjmp.h"
|
|
|
|
#include "../alice/alice.h"
|
|
|
|
//#include "../alice/all.h"
|
|
|
|
//#include "../alice/lls.h"
|
|
|
|
//#include "../alice/all_proto.h"
|
|
|
|
//#include "../jrd/gds_proto.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
#include "../jrd/thd_proto.h"
|
2003-01-16 18:47:10 +01:00
|
|
|
#include "../common/classes/alloc.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
//____________________________________________________________
|
|
|
|
//
|
|
|
|
// Get rid of everything.
|
|
|
|
//
|
|
|
|
|
|
|
|
void ALLA_fini(void)
|
|
|
|
{
|
2001-12-24 03:51:06 +01:00
|
|
|
TGBL tdgbl = GET_THREAD_DATA;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
for(tgbl::pool_vec_t::iterator curr = tdgbl->pools.begin();
|
|
|
|
curr != tdgbl->pools.end(); ++curr)
|
|
|
|
{
|
2003-01-16 18:47:10 +01:00
|
|
|
AliceMemoryPool::deletePool(*curr);
|
2001-12-24 03:51:06 +01:00
|
|
|
*curr = 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
2001-12-24 03:51:06 +01:00
|
|
|
tdgbl->pools.clear();
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-12-28 06:16:31 +01:00
|
|
|
tdgbl->ALICE_default_pool = 0;
|
|
|
|
tdgbl->ALICE_permanent_pool = 0;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//____________________________________________________________
|
|
|
|
//
|
|
|
|
// Initialize the pool system.
|
|
|
|
//
|
|
|
|
|
|
|
|
void ALLA_init(void)
|
|
|
|
{
|
|
|
|
TGBL tdgbl;
|
|
|
|
|
|
|
|
tdgbl = GET_THREAD_DATA;
|
2003-02-12 13:51:07 +01:00
|
|
|
#ifdef NOT_USED_OR_REPLACED
|
2001-12-24 03:51:06 +01:00
|
|
|
tdgbl->ALICE_default_pool = tdgbl->ALICE_permanent_pool =
|
|
|
|
AliceMemoryPool::create_new_pool();
|
|
|
|
#else
|
2001-12-28 06:16:31 +01:00
|
|
|
// TMN: John, what pool to use here?
|
2003-01-16 18:47:10 +01:00
|
|
|
tdgbl->ALICE_permanent_pool = AliceMemoryPool::createPool();
|
2001-12-28 06:16:31 +01:00
|
|
|
tdgbl->ALICE_default_pool = tdgbl->ALICE_permanent_pool;
|
2001-12-24 03:51:06 +01:00
|
|
|
#endif
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
void AliceMemoryPool::ALLA_push(class blk *object, class lls** stack)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2001-12-24 03:51:06 +01:00
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* A L L _ p u s h
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* Push an object on an LLS stack.
|
|
|
|
*
|
|
|
|
**************************************/
|
|
|
|
class lls* node;
|
|
|
|
AliceMemoryPool* pool;
|
|
|
|
|
|
|
|
TGBL tdgbl = GET_THREAD_DATA;
|
2001-05-23 15:26:42 +02:00
|
|
|
pool = tdgbl->ALICE_default_pool;
|
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
node = pool->lls_cache.newBlock();
|
2001-05-23 15:26:42 +02:00
|
|
|
node->lls_object = object;
|
|
|
|
node->lls_next = *stack;
|
|
|
|
*stack = node;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-10 14:28:35 +01:00
|
|
|
BLK AliceMemoryPool::ALLA_pop(LLS *stack)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2001-12-24 03:51:06 +01:00
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* A L L _ p o p
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* Pop an object off a linked list stack. Save the node for
|
|
|
|
* further use.
|
|
|
|
*
|
|
|
|
**************************************/
|
2003-02-10 14:28:35 +01:00
|
|
|
LLS node;
|
2001-12-24 03:51:06 +01:00
|
|
|
AliceMemoryPool* pool;
|
|
|
|
BLK object;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
node = *stack;
|
|
|
|
*stack = node->lls_next;
|
2001-12-24 03:51:06 +01:00
|
|
|
object = node->lls_object;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
pool = (AliceMemoryPool*)MemoryPool::blk_pool(node);
|
|
|
|
pool->lls_cache.returnBlock(node);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
return object;
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
2003-02-12 13:51:07 +01:00
|
|
|
#ifdef NOT_USED_OR_REPLACED
|
2001-12-24 03:51:06 +01:00
|
|
|
AliceMemoryPool* AliceMemoryPool::create_new_pool(MemoryPool* parent)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
2001-12-24 03:51:06 +01:00
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* A L L _ p o o l
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* Allocate a new pool.
|
|
|
|
*
|
|
|
|
**************************************/
|
|
|
|
|
|
|
|
TGBL tdgbl = GET_THREAD_DATA;
|
|
|
|
|
|
|
|
// TMN: John, is this correct?
|
|
|
|
AliceMemoryPool* pool = new(0, parent) AliceMemoryPool(parent);
|
|
|
|
tgbl::pool_vec_t::iterator curr;
|
|
|
|
|
|
|
|
for(curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
|
|
|
|
{
|
|
|
|
if (!*curr)
|
|
|
|
{
|
|
|
|
*curr = pool;
|
|
|
|
return pool;
|
|
|
|
}
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
tdgbl->pools.resize(tdgbl->pools.size() + 10);
|
|
|
|
for(curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
|
|
|
|
{
|
|
|
|
if (!*curr)
|
|
|
|
{
|
|
|
|
*curr = pool;
|
|
|
|
return pool;
|
|
|
|
}
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
//assert(0);
|
|
|
|
//BUGCHECK ("ALLA_fini - finishing before starting");
|
|
|
|
return 0;//pool; // Never reached, but makes the compiler happy.
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
2001-12-24 03:51:06 +01:00
|
|
|
#endif
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2003-01-16 18:47:10 +01:00
|
|
|
void AliceMemoryPool::deletePool(AliceMemoryPool* pool) {
|
2001-12-24 03:51:06 +01:00
|
|
|
TGBL tdgbl = GET_THREAD_DATA;
|
|
|
|
|
|
|
|
tgbl::pool_vec_t::iterator curr;
|
|
|
|
for(curr = tdgbl->pools.begin(); curr != tdgbl->pools.end(); ++curr)
|
|
|
|
{
|
2003-01-16 18:47:10 +01:00
|
|
|
if (*curr == pool)
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
|
|
|
*curr = 0;
|
2003-03-19 12:33:46 +01:00
|
|
|
break;
|
2001-12-24 03:51:06 +01:00
|
|
|
}
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
2003-01-16 18:47:10 +01:00
|
|
|
pool->lls_cache.~BlockCache<lls>();
|
|
|
|
MemoryPool::deletePool(pool);
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|