[DEV] clean getTime (single fucntion for allplatform ==> todo: remove it
This commit is contained in:
parent
4606ec35fd
commit
5fbe5f6ebb
@ -17,15 +17,6 @@
|
||||
#include <org_gale_GaleConstants.h>
|
||||
#include <jvm-basics/jvm-basics.hpp>
|
||||
|
||||
|
||||
int64_t gale::getTime() {
|
||||
struct timeval now;
|
||||
gettimeofday(&now, nullptr);
|
||||
//GALE_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
|
||||
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_usec);
|
||||
}
|
||||
|
||||
|
||||
// jni doc : /usr/lib/jvm/java-1.6.0-openjdk/include
|
||||
|
||||
std::mutex g_interfaceMutex;
|
||||
|
@ -28,20 +28,6 @@
|
||||
#include <mach/mach.h>
|
||||
#include <etk/etk.h>
|
||||
|
||||
|
||||
int64_t gale::getTime() {
|
||||
struct timespec now;
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t mts;
|
||||
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||
clock_get_time(cclock, &mts);
|
||||
mach_port_deallocate(mach_task_self(), cclock);
|
||||
now.tv_sec = mts.tv_sec;
|
||||
now.tv_nsec = mts.tv_nsec;
|
||||
//GALE_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
|
||||
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000);
|
||||
}
|
||||
|
||||
class MacOSInterface : public gale::Context {
|
||||
private:
|
||||
gale::key::Special m_guiKeyBoardMode;
|
||||
|
@ -31,19 +31,6 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
int64_t gale::getTime() {
|
||||
struct timespec now;
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t mts;
|
||||
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||
clock_get_time(cclock, &mts);
|
||||
mach_port_deallocate(mach_task_self(), cclock);
|
||||
now.tv_sec = mts.tv_sec;
|
||||
now.tv_nsec = mts.tv_nsec;
|
||||
//GALE_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
|
||||
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000);
|
||||
}
|
||||
|
||||
class MacOSInterface : public gale::Context {
|
||||
private:
|
||||
gale::key::Special m_guiKeyBoardMode;
|
||||
|
@ -23,13 +23,6 @@
|
||||
#include <windowsx.h>
|
||||
#include <etk/etk.hpp>
|
||||
|
||||
int64_t gale::getTime() {
|
||||
struct timeval now;
|
||||
gettimeofday(&now, nullptr);
|
||||
//GALE_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
|
||||
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_usec);
|
||||
}
|
||||
|
||||
static std::string GetLastErrorAsString() {
|
||||
//Get the error message, if any.
|
||||
DWORD errorMessageID = ::GetLastError();
|
||||
|
@ -50,18 +50,6 @@ bool hasDisplay = false;
|
||||
#define X11_CRITICAL GALE_VERBOSE
|
||||
#endif
|
||||
|
||||
int64_t gale::getTime() {
|
||||
struct timespec now;
|
||||
int ret = clock_gettime(CLOCK_REALTIME, &now);
|
||||
if (ret != 0) {
|
||||
// Error to get the time ...
|
||||
now.tv_sec = time(nullptr);
|
||||
now.tv_nsec = 0;
|
||||
}
|
||||
//GALE_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
|
||||
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000);
|
||||
}
|
||||
|
||||
// attributes for a single buffered visual in RGBA format with at least 4 bits per color and a 16 bit depth buffer
|
||||
static int attrListSgl[] = {
|
||||
GLX_RGBA,
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <gale/context/commandLine.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <gale/Dimension.hpp>
|
||||
#include <chrono>
|
||||
|
||||
#ifndef GALE_VERSION
|
||||
#define GALE_VERSION "0.0.0"
|
||||
@ -43,3 +44,10 @@ std::string gale::getVersion() {
|
||||
return GALE_VERSION;
|
||||
}
|
||||
|
||||
// generic vertion of time: ==> DEPRECATED
|
||||
int64_t gale::getTime() {
|
||||
std::chrono::high_resolution_clock::time_point globalTimePoint = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::microseconds timeSinceEpoch = std::chrono::duration_cast<std::chrono::microseconds>(globalTimePoint.time_since_epoch());
|
||||
return timeSinceEpoch.count();
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace gale {
|
||||
/**
|
||||
* @brief get current time in us...
|
||||
* @return The current time
|
||||
* @note is implemented by the OS implementation cf renderer/X11/...
|
||||
* @deprecated use std::chrono
|
||||
*/
|
||||
int64_t getTime();
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user