mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-29 18:20:44 +00:00
Remove base::thread, we use std::thread
This commit is contained in:
parent
7ede783926
commit
f5bc573bfc
2
laf
2
laf
@ -1 +1 @@
|
||||
Subproject commit 243fe983a984e49ded14bb953eae9b75b194b095
|
||||
Subproject commit 4c588f96774b6d651ae3d6ca70e97f7e290011af
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -135,7 +135,7 @@ void CheckUpdateThreadLauncher::launch()
|
||||
m_delegate->onCheckingUpdates();
|
||||
|
||||
m_bgJob.reset(new CheckUpdateBackgroundJob);
|
||||
m_thread.reset(new base::thread([this]{ checkForUpdates(); }));
|
||||
m_thread.reset(new std::thread([this]{ checkForUpdates(); }));
|
||||
|
||||
// Start a timer to monitoring the progress of the background job
|
||||
// executed in "m_thread". The "onMonitoringTick" method will be
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -11,12 +11,12 @@
|
||||
|
||||
#ifdef ENABLE_UPDATER
|
||||
|
||||
#include "base/thread.h"
|
||||
#include "ui/timer.h"
|
||||
#include "updater/check_update.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -46,7 +46,7 @@ namespace app {
|
||||
CheckUpdateDelegate* m_delegate;
|
||||
Preferences& m_preferences;
|
||||
updater::Uuid m_uuid;
|
||||
std::unique_ptr<base::thread> m_thread;
|
||||
std::unique_ptr<std::thread> m_thread;
|
||||
std::unique_ptr<CheckUpdateBackgroundJob> m_bgJob;
|
||||
bool m_doCheck;
|
||||
std::atomic<bool> m_received;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -27,7 +27,6 @@
|
||||
#include "app/ui/editor/editor_render.h"
|
||||
#include "app/ui/rgbmap_algorithm_selector.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "base/thread.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
@ -43,7 +42,9 @@
|
||||
#include "ui/size_hint_event.h"
|
||||
|
||||
#include "color_mode.xml.h"
|
||||
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -161,7 +162,7 @@ private:
|
||||
bool m_running;
|
||||
bool m_stopFlag;
|
||||
double m_progress;
|
||||
base::thread m_thread;
|
||||
std::thread m_thread;
|
||||
};
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -14,12 +14,15 @@
|
||||
#include "app/commands/filters/filter_manager_impl.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/editor/editor_render.h"
|
||||
#include "base/thread.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "ui/manager.h"
|
||||
#include "ui/message.h"
|
||||
#include "ui/widget.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace ui;
|
||||
@ -84,7 +87,7 @@ void FilterPreview::restartPreview()
|
||||
m_filterIsDone = false;
|
||||
m_timer.start();
|
||||
m_filterThread.reset(
|
||||
new base::thread([this]{ onFilterThread(); }));
|
||||
new std::thread([this]{ onFilterThread(); }));
|
||||
}
|
||||
|
||||
bool FilterPreview::onProcessMessage(Message* msg)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2022 Igara Studio S.A.
|
||||
// Copyright (C) 2022-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -9,11 +9,11 @@
|
||||
#define APP_COMMANDS_FILTERS_FILTER_PREVIEW_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "base/thread.h"
|
||||
#include "ui/timer.h"
|
||||
#include "ui/widget.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -39,7 +39,7 @@ namespace app {
|
||||
FilterManagerImpl* m_filterMgr;
|
||||
ui::Timer m_timer;
|
||||
std::mutex m_filterMgrMutex;
|
||||
std::unique_ptr<base::thread> m_filterThread;
|
||||
std::unique_ptr<std::thread> m_filterThread;
|
||||
bool m_filterIsDone;
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -6,8 +7,8 @@
|
||||
|
||||
#include "tests/app_test.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include "base/thread.h"
|
||||
#include <cerrno>
|
||||
#include <thread>
|
||||
|
||||
static void run_thread()
|
||||
{
|
||||
@ -22,7 +23,7 @@ TEST(Errno, ThreadSafe)
|
||||
|
||||
// Run another thread that will be modify the errno variable, and
|
||||
// wait it (join).
|
||||
base::thread thr(&run_thread);
|
||||
std::thread thr(&run_thread);
|
||||
thr.join();
|
||||
|
||||
// See if errno was not modified in this thread.
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2022 Igara Studio S.A.
|
||||
// Copyright (C) 2022-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -9,10 +9,9 @@
|
||||
#define APP_RES_HTTP_LOADER_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "base/thread.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
namespace net {
|
||||
class HttpRequest;
|
||||
@ -35,7 +34,7 @@ namespace app {
|
||||
std::string m_url;
|
||||
std::atomic<bool> m_done;
|
||||
net::HttpRequest* m_request;
|
||||
base::thread m_thread;
|
||||
std::thread m_thread;
|
||||
std::string m_filename;
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -24,7 +24,7 @@ ResourcesLoader::ResourcesLoader(std::unique_ptr<ResourcesLoaderDelegate>&& dele
|
||||
: m_delegate(std::move(delegate))
|
||||
, m_done(false)
|
||||
, m_cancel(false)
|
||||
, m_thread(new base::thread([this]{ threadLoadResources(); }))
|
||||
, m_thread(new std::thread([this]{ threadLoadResources(); }))
|
||||
{
|
||||
}
|
||||
|
||||
@ -83,9 +83,9 @@ void ResourcesLoader::threadLoadResources()
|
||||
}
|
||||
}
|
||||
|
||||
base::thread* ResourcesLoader::createThread()
|
||||
std::thread* ResourcesLoader::createThread()
|
||||
{
|
||||
return new base::thread([this]{ threadLoadResources(); });
|
||||
return new std::thread([this]{ threadLoadResources(); });
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -10,9 +10,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/concurrent_queue.h"
|
||||
#include "base/thread.h"
|
||||
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -31,7 +31,7 @@ namespace app {
|
||||
|
||||
private:
|
||||
void threadLoadResources();
|
||||
base::thread* createThread();
|
||||
std::thread* createThread();
|
||||
|
||||
typedef base::concurrent_queue<Resource*> Queue;
|
||||
|
||||
@ -39,7 +39,7 @@ namespace app {
|
||||
bool m_done;
|
||||
bool m_cancel;
|
||||
Queue m_queue;
|
||||
std::unique_ptr<base::thread> m_thread;
|
||||
std::unique_ptr<std::thread> m_thread;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
#include "base/concurrent_queue.h"
|
||||
#include "base/scoped_value.h"
|
||||
#include "base/thread.h"
|
||||
#include "base/time.h"
|
||||
#include "os/event.h"
|
||||
#include "os/event_queue.h"
|
||||
@ -31,7 +32,7 @@
|
||||
#include "ui/ui.h"
|
||||
|
||||
#if defined(DEBUG_PAINT_EVENTS) || defined(DEBUG_UI_THREADS)
|
||||
#include "base/thread.h"
|
||||
#include <thread>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
@ -82,7 +83,7 @@ typedef std::list<Filter*> Filters;
|
||||
Manager* Manager::m_defaultManager = nullptr;
|
||||
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
static base::thread::native_id_type manager_thread = 0;
|
||||
static std::thread::id manager_thread;
|
||||
#endif
|
||||
|
||||
static WidgetsList mouse_widgets_list; // List of widgets to send mouse events
|
||||
@ -208,8 +209,8 @@ Manager::Manager(const os::WindowRef& nativeWindow)
|
||||
nativeWindow->setUserData(&m_display);
|
||||
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(!manager_thread);
|
||||
manager_thread = base::this_thread::native_id();
|
||||
ASSERT(manager_thread == std::thread::id());
|
||||
manager_thread = std::this_thread::get_id();
|
||||
#endif
|
||||
|
||||
if (!m_defaultManager) {
|
||||
@ -237,7 +238,7 @@ Manager::Manager(const os::WindowRef& nativeWindow)
|
||||
Manager::~Manager()
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
// There are some messages in queue? Dispatch everything.
|
||||
@ -332,7 +333,7 @@ void Manager::updateAllDisplaysWithNewScale(int scale)
|
||||
bool Manager::generateMessages()
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
// First check: there are windows to manage?
|
||||
@ -398,7 +399,7 @@ static MouseButton mouse_button_from_os_to_ui(const os::Event& osEvent)
|
||||
void Manager::generateMessagesFromOSEvents()
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
os::Event lastMouseMoveEvent;
|
||||
@ -1100,7 +1101,7 @@ void Manager::freeCapture()
|
||||
void Manager::freeWidget(Widget* widget)
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
if (widget->hasFocus() || (widget == focus_widget))
|
||||
@ -1131,7 +1132,7 @@ void Manager::freeWidget(Widget* widget)
|
||||
void Manager::removeMessagesFor(Widget* widget)
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
for (Message* msg : msg_queue)
|
||||
@ -1144,7 +1145,7 @@ void Manager::removeMessagesFor(Widget* widget)
|
||||
void Manager::removeMessagesFor(Widget* widget, MessageType type)
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
for (Message* msg : msg_queue)
|
||||
@ -1159,7 +1160,7 @@ void Manager::removeMessagesFor(Widget* widget, MessageType type)
|
||||
void Manager::removeMessagesForTimer(Timer* timer)
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
for (Message* msg : msg_queue) {
|
||||
@ -1182,7 +1183,7 @@ void Manager::removeMessagesForTimer(Timer* timer)
|
||||
void Manager::removeMessagesForDisplay(Display* display)
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
for (Message* msg : msg_queue) {
|
||||
@ -1203,7 +1204,7 @@ void Manager::removeMessagesForDisplay(Display* display)
|
||||
void Manager::removePaintMessagesForDisplay(Display* display)
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
for (auto it=msg_queue.begin(); it != msg_queue.end(); ) {
|
||||
@ -1221,7 +1222,7 @@ void Manager::removePaintMessagesForDisplay(Display* display)
|
||||
void Manager::addMessageFilter(int message, Widget* widget)
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
LockFilters lock;
|
||||
@ -1235,7 +1236,7 @@ void Manager::addMessageFilter(int message, Widget* widget)
|
||||
void Manager::removeMessageFilter(int message, Widget* widget)
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
LockFilters lock;
|
||||
@ -1253,7 +1254,7 @@ void Manager::removeMessageFilter(int message, Widget* widget)
|
||||
void Manager::removeMessageFilterFor(Widget* widget)
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
LockFilters lock;
|
||||
@ -1802,7 +1803,7 @@ void Manager::onSizeHint(SizeHintEvent& ev)
|
||||
int Manager::pumpQueue()
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
#ifdef LIMIT_DISPATCH_TIME
|
||||
@ -1876,7 +1877,7 @@ int Manager::pumpQueue()
|
||||
bool Manager::sendMessageToWidget(Message* msg, Widget* widget)
|
||||
{
|
||||
#ifdef DEBUG_UI_THREADS
|
||||
ASSERT(manager_thread == base::this_thread::native_id());
|
||||
ASSERT(manager_thread == std::this_thread::get_id());
|
||||
#endif
|
||||
|
||||
if (!widget)
|
||||
@ -1953,7 +1954,7 @@ bool Manager::sendMessageToWidget(Message* msg, Widget* widget)
|
||||
|
||||
#ifdef DEBUG_PAINT_EVENTS
|
||||
{
|
||||
os::SurfaceLock lock(surface);
|
||||
os::SurfaceLock lock(surface.get());
|
||||
os::Paint p;
|
||||
p.color(gfx::rgba(0, 0, 255));
|
||||
p.style(os::Paint::Fill);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "ui/system.h"
|
||||
|
||||
#include "base/thread.h"
|
||||
#include "gfx/point.h"
|
||||
#include "os/event.h"
|
||||
#include "os/event_queue.h"
|
||||
@ -29,11 +28,13 @@
|
||||
#include "ui/theme.h"
|
||||
#include "ui/widget.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
namespace ui {
|
||||
|
||||
// This is used to check if calls to UI layer are made from the non-UI
|
||||
// thread. (Which might be catastrofic.)
|
||||
base::thread::native_id_type main_gui_thread;
|
||||
std::thread::id main_gui_thread;
|
||||
|
||||
// Multiple displays (create one os::Window for each ui::Window)
|
||||
bool multi_displays = false;
|
||||
@ -218,7 +219,7 @@ UISystem::UISystem()
|
||||
ASSERT(!g_instance);
|
||||
g_instance = this;
|
||||
|
||||
main_gui_thread = base::this_thread::native_id();
|
||||
main_gui_thread = std::this_thread::get_id();
|
||||
mouse_cursor_type = kOutsideDisplay;
|
||||
support_native_custom_cursor =
|
||||
((os::instance() &&
|
||||
@ -379,7 +380,7 @@ void execute_from_ui_thread(std::function<void()>&& func)
|
||||
|
||||
bool is_ui_thread()
|
||||
{
|
||||
return (main_gui_thread == base::this_thread::native_id());
|
||||
return (main_gui_thread == std::this_thread::get_id());
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user