Added nanosecond info of last module modification
parent
4deba61a09
commit
c76f0959ff
|
@ -57,6 +57,7 @@ void RuntimeModuleManager::LoadModule(RuntimeModule* module) {
|
||||||
module->handle = handle;
|
module->handle = handle;
|
||||||
module->id = attr.st_ino;
|
module->id = attr.st_ino;
|
||||||
module->mtime = attr.st_mtime;
|
module->mtime = attr.st_mtime;
|
||||||
|
module->mtimensec = attr.st_mtim.tv_nsec;
|
||||||
const struct module_api *api = (module_api*) dlsym(module->handle, "MODULE_API");
|
const struct module_api *api = (module_api*) dlsym(module->handle, "MODULE_API");
|
||||||
if (api != NULL) {
|
if (api != NULL) {
|
||||||
module->api = *api;
|
module->api = *api;
|
||||||
|
@ -83,17 +84,6 @@ void RuntimeModuleManager::LoadModule(RuntimeModule* module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuntimeModuleManager::Update(float dt) {
|
void RuntimeModuleManager::Update(float dt) {
|
||||||
if (CheckModulesChanged()) {
|
|
||||||
std::cout << "Detected module update. Unloading all modules." << std::endl;
|
|
||||||
|
|
||||||
UnloadModules();
|
|
||||||
|
|
||||||
// We need to sleep to make sure we load the new files
|
|
||||||
usleep(300000);
|
|
||||||
|
|
||||||
LoadModules();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = mModules.size() - 1; i >= 0; i--) {
|
for (int i = mModules.size() - 1; i >= 0; i--) {
|
||||||
if (mModules[i]->handle) {
|
if (mModules[i]->handle) {
|
||||||
mModules[i]->api.step(mModules[i]->state, dt);
|
mModules[i]->api.step(mModules[i]->state, dt);
|
||||||
|
|
|
@ -13,6 +13,7 @@ struct RuntimeModule {
|
||||||
ino_t id = 0;
|
ino_t id = 0;
|
||||||
void *data = nullptr;
|
void *data = nullptr;
|
||||||
int mtime = 0;
|
int mtime = 0;
|
||||||
|
int mtimensec = 0;
|
||||||
|
|
||||||
struct module_api api;
|
struct module_api api;
|
||||||
struct module_state *state = nullptr;
|
struct module_state *state = nullptr;
|
||||||
|
|
11
src/main.cc
11
src/main.cc
|
@ -122,6 +122,17 @@ int main(void)
|
||||||
|
|
||||||
float time = (float)( (now-time_offset)/double(bx::getHPFrequency() ) );
|
float time = (float)( (now-time_offset)/double(bx::getHPFrequency() ) );
|
||||||
|
|
||||||
|
if (module_manager.CheckModulesChanged()) {
|
||||||
|
std::cout << "Detected module update. Unloading all modules." << std::endl;
|
||||||
|
module_manager.UnloadModules();
|
||||||
|
// We need to sleep to make sure we load the new files
|
||||||
|
usleep(300000);
|
||||||
|
module_manager.LoadModules();
|
||||||
|
// We need to update our last timestamp to ignore the delay due
|
||||||
|
// to reloading of the modules.
|
||||||
|
last = bx::getHPCounter();
|
||||||
|
}
|
||||||
|
|
||||||
module_manager.Update((float)(frameTime / freq));
|
module_manager.Update((float)(frameTime / freq));
|
||||||
|
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
|
@ -411,9 +411,11 @@ void ShowModulesWindow(struct module_state *state) {
|
||||||
ImGui::LabelText("File", "%s", selected_module->name.c_str());
|
ImGui::LabelText("File", "%s", selected_module->name.c_str());
|
||||||
ImGui::LabelText("Handle", "0x%p", selected_module->handle);
|
ImGui::LabelText("Handle", "0x%p", selected_module->handle);
|
||||||
ImGui::LabelText("id", "%ld", selected_module->id);
|
ImGui::LabelText("id", "%ld", selected_module->id);
|
||||||
|
ImGui::LabelText("mtime", "%ld", selected_module->mtime);
|
||||||
|
ImGui::LabelText("mtimensec", "%ld", selected_module->mtimensec);
|
||||||
|
|
||||||
ctime_r((time_t*)&selected_module->mtime, time_buf);
|
// ImGui::LabelText("mtime", "%s", ctime((time_t*)&selected_module->mtime));
|
||||||
ImGui::LabelText("mtime", "%s", time_buf);
|
// cout << "time_buf = " << ctime((time_t*)&selected_module->mtime) << endl;
|
||||||
|
|
||||||
if (ImGui::Button ("Force Reload")) {
|
if (ImGui::Button ("Force Reload")) {
|
||||||
selected_module->mtime = 0;
|
selected_module->mtime = 0;
|
||||||
|
|
Loading…
Reference in New Issue