add System::now()

This commit is contained in:
Joel Dice 2007-08-18 16:35:22 -06:00
parent 215a52ba54
commit 3bbc119516
2 changed files with 9 additions and 10 deletions

View File

@ -112,15 +112,6 @@ handleSignal(int)
// ignore
}
int64_t
now()
{
timeval tv = { 0, 0 };
gettimeofday(&tv, 0);
return (static_cast<int64_t>(tv.tv_sec) * 1000) +
(static_cast<int64_t>(tv.tv_usec) / 1000);
}
void*
run(void* r)
{
@ -269,7 +260,7 @@ class MySystem: public System {
pthread_mutex_unlock(&mutex);
if (time) {
int64_t then = now() + time;
int64_t then = s->now() + time;
timespec ts = { then / 1000, (then % 1000) * 1000 * 1000 };
int rv = pthread_cond_timedwait
(&(t->condition), &(t->mutex), &ts);
@ -518,6 +509,13 @@ class MySystem: public System {
::exit(code);
}
int64_t now() {
timeval tv = { 0, 0 };
gettimeofday(&tv, 0);
return (static_cast<int64_t>(tv.tv_sec) * 1000) +
(static_cast<int64_t>(tv.tv_usec) / 1000);
}
virtual void abort() {
::abort();
}

View File

@ -67,6 +67,7 @@ class System: public Allocator {
unsigned returnType) = 0;
virtual Status load(Library**, const char* name, Library* next) = 0;
virtual void exit(int code) = 0;
virtual int64_t now() = 0;
virtual void abort() = 0;
virtual void dispose() = 0;