Patch level : 2.0 610

Files correlati     : tutti
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@11519 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2003-10-21 11:23:47 +00:00
parent 39102f264b
commit 7e73be6971
2 changed files with 19 additions and 3 deletions

View File

@ -427,6 +427,7 @@ TFile_cache::TFile_cache(TLocalisamfile *f , int key)
{
_filecode << f->num();
init_file(f);
_last_change_test = clock();
}
TFile_cache::TFile_cache(int num, int key)
@ -434,6 +435,7 @@ TFile_cache::TFile_cache(int num, int key)
_test_changes(FALSE), _last_read(0), _limit(0)
{
_filecode << num;
_last_change_test = clock();
}
TFile_cache::TFile_cache(const char* tab, int key)
@ -441,6 +443,7 @@ TFile_cache::TFile_cache(const char* tab, int key)
_test_changes(FALSE), _last_read(0), _limit(0)
{
_filecode = tab;
_last_change_test = clock();
}
TFile_cache::~TFile_cache()
@ -491,6 +494,11 @@ void TFile_cache::init_file(TLocalisamfile* f)
}
}
void TFile_cache::notify_change()
{
_last_change_test = 0;
}
void TFile_cache::test_firm()
{
if (_last_firm < -1)
@ -510,8 +518,12 @@ void TFile_cache::test_firm()
if (_test_changes)
{
if (_file != NULL && _file->is_changed_since(_last_read))
flush_needed = TRUE;
if (_file != NULL)
{
const clock_t next_test = _last_change_test + 10000;
if (clock() > next_test)
flush_needed =_file->is_changed_since(_last_read);
}
}
if (_limit > 0 && items() > _limit)
@ -521,6 +533,7 @@ void TFile_cache::test_firm()
{
flush();
destroy();
_last_change_test = clock();
}
}
@ -722,6 +735,7 @@ const TString& TRecord_cache::get(long key, const char* field)
{
return get(key).get(field);
}
///////////////////////////////////////////////////////////
// TDB_cache
///////////////////////////////////////////////////////////

View File

@ -155,6 +155,7 @@ class TFile_cache : public TObject
int _error;
long _last_read, _limit;
bool _test_changes;
unsigned long _last_change_test;
protected:
TAssoc_array _cache;
@ -187,7 +188,8 @@ public:
void set_items_limit(long l) { _limit = l; }
void test_file_changes(bool t = TRUE) { _test_changes = t; }
void notify_change();
static void stats(unsigned long& hits, unsigned long& misses);
TFile_cache(TLocalisamfile *f,int key = 1);