this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
3/*
4 * Main authors:
5 * Guido Tack <guido.tack@monash.edu>
6 */
7
8/* This Source Code Form is subject to the terms of the Mozilla Public
9 * License, v. 2.0. If a copy of the MPL was not distributed with this
10 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
11
12#include <minizinc/process.hh>
13
14namespace MiniZinc {
15
16#ifdef _WIN32
17
18void TimeOut(HANDLE hProcess, bool* doneStdout, bool* doneStderr, int timeout,
19 std::timed_mutex* mtx) {
20 if (timeout > 0) {
21 if (!mtx->try_lock_for(std::chrono::milliseconds(timeout))) {
22 if ((!*doneStdout) || (!*doneStderr)) {
23 *doneStdout = true;
24 *doneStderr = true;
25 TerminateProcess(hProcess, 0);
26 }
27 }
28 }
29}
30#endif
31
32} // namespace MiniZinc