mirror of
https://github.com/corda/corda.git
synced 2024-12-28 16:58:55 +00:00
add System::now()
This commit is contained in:
parent
215a52ba54
commit
3bbc119516
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user