boostorg / boostorg/fiber

Can I adjust the accuracy of timer?

Open
#295 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
510
Forks
123
PR merge metrics
No merged PRs in 30d

Description

Failed to achieve FPS 60 ( frame per second) :
```
auto timenow() {
return std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count();
}

int main() {
boost::fibers::fiber mainFiber([]()
{
while (true) {
auto now = timenow();
boost::this_fiber::sleep_for(std::chrono::milliseconds(16));
std::cout << timenow() - now << "\n";
}
});
mainFiber.join();
}
```

Outputs ( should be 16 ):

```
34
27
30
31
31
31
30
31
30
29
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.