Skip to content

Commit 55679bd

Browse files
committed
Minor formatting adjustments
1 parent 621def3 commit 55679bd

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

_posts/2025-02-20-why-sleep-for-is-broken-on-esp32.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: "Why `std::this_thread::sleep_for()` is broken on ESP32"
2+
title: "Why std::this_thread::sleep_for() is broken on ESP32"
33
description:
4-
A deep dive into how `std::this_thread::sleep_for()` is implemented on ESP32,
4+
A deep dive into how std::this_thread::sleep_for() is implemented on ESP32,
55
and why it is broken in IDF v5.
66
author: stevenoonan
77
tags: [esp32, freertos, c++, c, idf]
@@ -208,11 +208,11 @@ Let's look at the working side of things first. When calling
208208
`std::this_thread::sleep_for(10ms)` we first enter here:
209209

210210
```c++
211-
/// sleep_for
212-
template<typename _Rep, typename _Period>
213-
inline void
214-
sleep_for(const chrono::duration<_Rep, _Period>& __rtime)
215-
{
211+
/// sleep_for
212+
template<typename _Rep, typename _Period>
213+
inline void
214+
sleep_for(const chrono::duration<_Rep, _Period>& __rtime)
215+
{
216216
if (__rtime <= __rtime.zero())
217217
return;
218218
auto __s = chrono::duration_cast<chrono::seconds>(__rtime);
@@ -228,7 +228,7 @@ Let's look at the working side of things first. When calling
228228
#else
229229
__sleep_for(__s, __ns);
230230
#endif
231-
}
231+
}
232232
```
233233
234234
If you are following along in your own IDF project, you can find the
@@ -299,7 +299,6 @@ Let's clean it up by taking out the parts not compiled for the ESP32:
299299
::usleep(__us);
300300
}
301301
}
302-
}
303302
```
304303
305304
Pretty simple: get the number of seconds and call `sleep()`, then get the number

0 commit comments

Comments
 (0)