00001 /* 00002 ** (c) 1996-2000 The Regents of the University of California (through 00003 ** E.O. Lawrence Berkeley National Laboratory), subject to approval by 00004 ** the U.S. Department of Energy. Your use of this software is under 00005 ** license -- the license agreement is attached and included in the 00006 ** directory as license.txt or you may contact Berkeley Lab's Technology 00007 ** Transfer Department at TTD@lbl.gov. NOTICE OF U.S. GOVERNMENT RIGHTS. 00008 ** The Software was developed under funding from the U.S. Government 00009 ** which consequently retains certain rights as follows: the 00010 ** U.S. Government has been granted for itself and others acting on its 00011 ** behalf a paid-up, nonexclusive, irrevocable, worldwide license in the 00012 ** Software to reproduce, prepare derivative works, and perform publicly 00013 ** and display publicly. Beginning five (5) years after the date 00014 ** permission to assert copyright is obtained from the U.S. Department of 00015 ** Energy, and subject to any subsequent five (5) year renewals, the 00016 ** U.S. Government is granted for itself and others acting on its behalf 00017 ** a paid-up, nonexclusive, irrevocable, worldwide license in the 00018 ** Software to reproduce, prepare derivative works, distribute copies to 00019 ** the public, perform publicly and display publicly, and to permit 00020 ** others to do so. 00021 */ 00022 00023 00024 #include <winstd.H> 00025 00026 #include <BaseFab.H> 00027 #include <BArena.H> 00028 #include <CArena.H> 00029 #include <Thread.H> 00030 00031 int BoxLib::BF_init::m_cnt = 0; 00032 00033 static ThreadSpecificData<Arena>* arena = 0; 00034 00035 BoxLib::BF_init::BF_init () 00036 { 00037 if (m_cnt++ == 0) 00038 arena = new ThreadSpecificData<Arena>; 00039 } 00040 00041 BoxLib::BF_init::~BF_init () 00042 { 00043 if (--m_cnt == 0) 00044 delete arena; 00045 } 00046 00047 Arena* 00048 BoxLib::ResetArena (Arena* newarena) 00049 { 00050 BL_ASSERT(newarena != 0); 00051 00052 Arena* oldarena = arena->get(); 00053 00054 BL_ASSERT(oldarena != 0); 00055 00056 arena->set(newarena); 00057 00058 return oldarena; 00059 } 00060 00061 Arena* 00062 BoxLib::The_Arena () 00063 { 00064 BL_ASSERT(arena != 0); 00065 00066 Arena* a = arena->get(); 00067 00068 if (a == 0) 00069 { 00070 arena->set(a = new BArena); 00071 } 00072 00073 return a; 00074 } 00075