diff options
Diffstat (limited to 'build2/scheduler.cxx')
-rw-r--r-- | build2/scheduler.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/build2/scheduler.cxx b/build2/scheduler.cxx index 2438d0b..053532e 100644 --- a/build2/scheduler.cxx +++ b/build2/scheduler.cxx @@ -11,6 +11,14 @@ # endif #endif +#ifndef _WIN32 +# include <thread> // this_thread::sleep_for() +#else +# include <libbutl/win32-utility.hxx> + +# include <chrono> +#endif + #include <cerrno> #include <exception> // std::terminate() @@ -175,6 +183,24 @@ namespace build2 throw_generic_error (ECANCELED); } + void scheduler:: + sleep (const duration& d) + { + deactivate (); + + // MINGW GCC 4.9 doesn't implement this_thread so use Win32 Sleep(). + // +#ifndef _WIN32 + this_thread::sleep_for (d); +#else + using namespace chrono; + + Sleep (static_cast<DWORD> (duration_cast<milliseconds> (d).count ())); +#endif + + activate (); + } + size_t scheduler:: suspend (size_t start_count, const atomic_count& task_count) { |