Skip to content

Conversation

@shikokuchuo
Copy link
Member

@shikokuchuo shikokuchuo commented Dec 1, 2025

Fixes #32.

Summary of changes:

File: src/fswatch-5c443d2/libfswatch/src/libfswatch/c++/windows_monitor.cpp

Add headers:

#include <thread>
#include <chrono>

Replace line 232:

// OLD:
sleep(latency);

// NEW:
std::this_thread::sleep_for(std::chrono::milliseconds((long long) (latency * 1000)));

Fixes bug:

POSIX sleep() from <unistd.h> has the following signature:

unsigned int sleep(unsigned int seconds);

This leads to an implicit truncation when a double < 1.0 is passed to sleep():
e.g. sleep(0.5)sleep(0)

@shikokuchuo shikokuchuo merged commit eca8238 into main Dec 1, 2025
20 checks passed
@shikokuchuo shikokuchuo deleted the dev branch December 1, 2025 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

High CPU usage

2 participants