mirror of https://github.com/eeeneko/ovo.git
parent
7e321c901f
commit
6a7df6e126
1 changed files with 38 additions and 0 deletions
@ -0,0 +1,38 @@ |
||||
## Class Timer |
||||
|
||||
**To use this class, you need to put `#define _pthread` before your `#include "ovo.h"` ** |
||||
**And also, use `g++ yourCode.cpp -std=c++14 -pthread` to compile** |
||||
--------- |
||||
### Timer.setTimeout() |
||||
This can let your be executed after certain time. |
||||
#### Params: |
||||
- **auto function** Your function. `Lambda Expression is allowed!` |
||||
- **int delay** Time to delay in milliseconds. |
||||
|
||||
#### Example |
||||
````C++ |
||||
#include <iostream> |
||||
#include <string> |
||||
|
||||
#define _pthread |
||||
|
||||
#include "ovo.h" |
||||
|
||||
using namespace std; |
||||
|
||||
void display(){ |
||||
cout << "Hey.. After 1s." << endl; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
ovo::Timer t = ovo::Timer(); |
||||
t.setsetTimeout(dis, 1000); |
||||
|
||||
while (1); //Keep the main thread never stop |
||||
return 0; |
||||
} |
||||
```` |
||||
This will get the following result. (Use Ctrl+C to interrupt) |
||||
>Hey.. After 1s. |
||||
|
Loading…
Reference in new issue