forked from qt-creator/qt-creator
Get rid of Utils::sleep
Replace with std::this_thread::sleep_for() Change-Id: I3a02fa6d4fc1b41d8d7b01bb3ba0342ce49b8e61 Reviewed-by: BogDan Vatra <bogdan@kdab.com> Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
8edda219d9
commit
88aa956bb7
@@ -1,43 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 Orgad Shaneh <orgads@gmail.com>.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "sleep.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
void Utils::sleep(int msec)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
::Sleep(msec);
|
||||
#else
|
||||
struct timespec ts = { msec / 1000, (msec % 1000) * 1000000 };
|
||||
::nanosleep(&ts, NULL);
|
||||
#endif
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 Orgad Shaneh <orgads@gmail.com>.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
namespace Utils {
|
||||
|
||||
void QTCREATOR_UTILS_EXPORT sleep(int msec);
|
||||
|
||||
}
|
||||
@@ -72,7 +72,6 @@ SOURCES += $$PWD/environment.cpp \
|
||||
$$PWD/json.cpp \
|
||||
$$PWD/portlist.cpp \
|
||||
$$PWD/appmainwindow.cpp \
|
||||
$$PWD/sleep.cpp \
|
||||
$$PWD/basetreeview.cpp \
|
||||
$$PWD/qtcassert.cpp \
|
||||
$$PWD/elfreader.cpp \
|
||||
@@ -173,7 +172,6 @@ HEADERS += \
|
||||
$$PWD/runextensions.h \
|
||||
$$PWD/portlist.h \
|
||||
$$PWD/appmainwindow.h \
|
||||
$$PWD/sleep.h \
|
||||
$$PWD/basetreeview.h \
|
||||
$$PWD/elfreader.h \
|
||||
$$PWD/bracematcher.h \
|
||||
|
||||
@@ -190,8 +190,6 @@ Project {
|
||||
"shellcommandpage.cpp",
|
||||
"shellcommandpage.h",
|
||||
"sizedarray.h",
|
||||
"sleep.cpp",
|
||||
"sleep.h",
|
||||
"smallstring.h",
|
||||
"smallstringiterator.h",
|
||||
"smallstringio.h",
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
#include <utils/persistentsettings.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/runextensions.h>
|
||||
#include <utils/sleep.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
|
||||
#include <QApplication>
|
||||
@@ -64,7 +63,9 @@
|
||||
#include <QStringList>
|
||||
#include <QTcpSocket>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
@@ -825,7 +826,7 @@ bool AndroidConfig::waitForBooted(const QString &serialNumber, const QFutureInte
|
||||
if (hasFinishedBooting(serialNumber)) {
|
||||
return true;
|
||||
} else {
|
||||
Utils::sleep(2000);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
if (!isConnected(serialNumber)) // device was disconnected
|
||||
return false;
|
||||
}
|
||||
@@ -844,7 +845,7 @@ QString AndroidConfig::waitForAvd(const QString &avdName, const QFutureInterface
|
||||
serialNumber = findAvd(avdName);
|
||||
if (!serialNumber.isEmpty())
|
||||
return waitForBooted(serialNumber, fi) ? serialNumber : QString();
|
||||
Utils::sleep(2000);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user