Skip to content

Excessive CPU usage on Windows when latency < 1 #349

@shikokuchuo

Description

@shikokuchuo

As reported in the R binding to libfswatch here: r-lib/watcher#32 (comment).

File: libfswatch/src/libfswatch/c++/windows_monitor.cpp:234

sleep(latency);

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions