📜  c 分数睡眠 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:41.189000             🧑  作者: Mango

代码示例1
#define _DEFAULT_SOURCE
#include "newSleep.h"

void fracSleep(float sec) {
    struct timespec ts;
    ts.tv_sec = (int) sec;
    ts.tv_nsec = (sec - ((int) sec)) * 1000000000;
    nanosleep(&ts,NULL);
}

fracSleep(0.5); //Half second delay