1
1
forked from 0ad/0ad

wposix: fix for USE_MMGR: undef getcwd

singleton: switch to assert2
loader: simpler HaveTimeForNextTask check

This was SVN commit r2056.
This commit is contained in:
janwas 2005-03-27 01:37:10 +00:00
parent 12eab0ded6
commit ba636ca96c
3 changed files with 11 additions and 15 deletions

View File

@ -266,6 +266,7 @@ extern int close(int);
_CRTIMP int access(const char*, int);
extern int chdir(const char*);
#undef getcwd
extern char* getcwd(char*, size_t);
// user tests if available via #ifdef; can't use enum.

View File

@ -161,16 +161,11 @@ static bool HaveTimeForNextTask(double time_left, double time_budget, int estima
if(time_left <= 0.0)
return false;
// we've already used up more than 60%:
// (if it's less than that, we won't check the next task length)
if(time_left < 0.40*time_budget)
{
const double estimated_duration = estimated_duration_ms*1e-3;
// .. and the upcoming task is expected to be long -
// leave it for the next timeslice.
if(estimated_duration > time_left + time_budget*0.20)
return false;
}
// check next task length. we want a lengthy task to happen in its own
// timeslice so that its description is displayed beforehand.
const double estimated_duration = estimated_duration_ms*1e-3;
if(time_left+estimated_duration > time_budget*1.20)
return false;
return true;
}
@ -252,7 +247,7 @@ int LDR_ProgressiveLoad(double time_budget, wchar_t* description_,
// check if we're out of time; take into account next task length.
// note: do this at the end of the loop to make sure there's
// progress even if the timer is low-resolution (=> time_left = 0).
// if(!HaveTimeForNextTask(time_left, time_budget, lr.estimated_duration_ms))
if(!HaveTimeForNextTask(time_left, time_budget, lr.estimated_duration_ms))
{
ret = ERR_TIMED_OUT;
goto done;

View File

@ -31,7 +31,7 @@ class Singleton
public:
Singleton()
{
assert( !ms_singleton );
assert2( !ms_singleton );
//use a cunning trick to get the singleton pointing to the start of
//the whole, rather than the start of the Singleton part of the object
@ -41,19 +41,19 @@ class Singleton
~Singleton()
{
assert( ms_singleton );
assert2( ms_singleton );
ms_singleton=0;
}
static T& GetSingleton()
{
assert( ms_singleton );
assert2( ms_singleton );
return *ms_singleton;
}
static T* GetSingletonPtr()
{
assert( ms_singleton );
assert2( ms_singleton );
return ms_singleton;
}