eglimi / cpptime Goto Github PK
View Code? Open in Web Editor NEWA portable, pure C++11 timer component.
License: MIT License
A portable, pure C++11 timer component.
License: MIT License
Hi,
I just tested this great timer on both Windows and Ubuntu.
When I set the system time both backward and forward, the timer always invokes the callback function.
But on Ubuntu it only works when I set the system time forward.
I have no idea what's wrong with this code, or the Linux system. Thanks!
Leo
qestion1 :
thread1 add a period timer and save time_id.
thread2 is the timer thread.
afer thread2 unlock .
thread 1 use the time_id to call Timer::remove() ,
in Timer::remove , delete the time_id and set handler to nullptr,
but thread 1 is executing the handler.
the coredump happen.
lock.unlock();
events[te.ref].handler(te.ref);
lock.lock();
what should i do to avoid the problem?
question 2:
thread1 add a period timer and save time_id.
thread2 is the timer thread.
thread 1 will call Timer::remove() in handler callback.
while the handler is executing ,it call Timer::remove, But in Timer::remove set handler to nullptr .
and so the program core dump.
events[id].valid = false;
events[id].handler = nullptr;
I think there is a bug:
remove(0) (if no timer is active/ever used) will pass the
if(events.size()< id) {
return false;
}
check (events.size()==0 not < 0)
but in the end there is no item. So the check should be extended to e.g.
if (events.size()>0 && events.size()<id)
or id being started with 1 for the first item?
Is it possible to extend the timer functionality to pass input argument((void *)arg) to handler function?
We are encountering a serious issue on MacOS where the timeouts are not occurring after some time. The function ´run()´ is waiting for work and inserting time events during the same lock (!). This should be refactored.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.