diff options
author | Andreas Kling <kling@serenityos.org> | 2021-05-22 18:47:42 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-22 18:54:22 +0200 |
commit | b5d73c834ff0f4cb1ff6112f055bee4cd02b21ec (patch) | |
tree | 82aae5e6a9d2d798b9810770b15f2a9d3cb04161 /Userland | |
parent | 5729b4e9a5658d8728239e3141ff270004af5d6c (diff) | |
download | serenity-b5d73c834ff0f4cb1ff6112f055bee4cd02b21ec.zip |
Userland: Rename LibThread => LibThreading
Also rename the "LibThread" namespace to "Threading"
Diffstat (limited to 'Userland')
24 files changed, 68 insertions, 68 deletions
diff --git a/Userland/Applications/Piano/main.cpp b/Userland/Applications/Piano/main.cpp index 76643e60db..7983b040d3 100644 --- a/Userland/Applications/Piano/main.cpp +++ b/Userland/Applications/Piano/main.cpp @@ -21,7 +21,7 @@ #include <LibGUI/MessageBox.h> #include <LibGUI/Window.h> #include <LibGfx/Bitmap.h> -#include <LibThread/Thread.h> +#include <LibThreading/Thread.h> int main(int argc, char** argv) { @@ -49,7 +49,7 @@ int main(int argc, char** argv) Optional<String> save_path; bool need_to_write_wav = false; - auto audio_thread = LibThread::Thread::construct([&] { + auto audio_thread = Threading::Thread::construct([&] { auto audio = Core::File::construct("/dev/audio"); if (!audio->open(Core::OpenMode::WriteOnly)) { dbgln("Can't open audio device: {}", audio->error_string()); diff --git a/Userland/DevTools/HackStudio/Debugger/Debugger.h b/Userland/DevTools/HackStudio/Debugger/Debugger.h index 579f5574e6..f485c5c4f5 100644 --- a/Userland/DevTools/HackStudio/Debugger/Debugger.h +++ b/Userland/DevTools/HackStudio/Debugger/Debugger.h @@ -11,8 +11,8 @@ #include <AK/LexicalPath.h> #include <AK/Vector.h> #include <LibDebug/DebugSession.h> -#include <LibThread/Lock.h> -#include <LibThread/Thread.h> +#include <LibThreading/Lock.h> +#include <LibThreading/Thread.h> namespace HackStudio { diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index f8e6c04a63..8abd23e15b 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -60,8 +60,8 @@ #include <LibGUI/Window.h> #include <LibGfx/FontDatabase.h> #include <LibGfx/Palette.h> -#include <LibThread/Lock.h> -#include <LibThread/Thread.h> +#include <LibThreading/Lock.h> +#include <LibThreading/Thread.h> #include <LibVT/TerminalWidget.h> #include <fcntl.h> #include <spawn.h> @@ -621,7 +621,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_debug_action() } Debugger::the().set_executable_path(get_project_executable_path()); - m_debugger_thread = LibThread::Thread::construct(Debugger::start_static); + m_debugger_thread = Threading::Thread::construct(Debugger::start_static); m_debugger_thread->start(); m_stop_action->set_enabled(true); }); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.h b/Userland/DevTools/HackStudio/HackStudioWidget.h index b352ef202c..1dd385f54f 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.h +++ b/Userland/DevTools/HackStudio/HackStudioWidget.h @@ -23,7 +23,7 @@ #include <LibGUI/Scrollbar.h> #include <LibGUI/Splitter.h> #include <LibGUI/Widget.h> -#include <LibThread/Thread.h> +#include <LibThreading/Thread.h> namespace HackStudio { @@ -144,7 +144,7 @@ private: RefPtr<FindInFilesWidget> m_find_in_files_widget; RefPtr<DebugInfoWidget> m_debug_info_widget; RefPtr<DisassemblyWidget> m_disassembly_widget; - RefPtr<LibThread::Thread> m_debugger_thread; + RefPtr<Threading::Thread> m_debugger_thread; RefPtr<EditorWrapper> m_current_editor_in_execution; RefPtr<GUI::Action> m_new_file_action; diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp index b54d82e207..436b1122a1 100644 --- a/Userland/DevTools/HackStudio/main.cpp +++ b/Userland/DevTools/HackStudio/main.cpp @@ -19,8 +19,8 @@ #include <LibGUI/Notification.h> #include <LibGUI/Widget.h> #include <LibGUI/Window.h> -#include <LibThread/Lock.h> -#include <LibThread/Thread.h> +#include <LibThreading/Lock.h> +#include <LibThreading/Thread.h> #include <LibVT/TerminalWidget.h> #include <fcntl.h> #include <spawn.h> diff --git a/Userland/Libraries/CMakeLists.txt b/Userland/Libraries/CMakeLists.txt index 63f5b6f3d7..e3ae34ecaf 100644 --- a/Userland/Libraries/CMakeLists.txt +++ b/Userland/Libraries/CMakeLists.txt @@ -37,7 +37,7 @@ add_subdirectory(LibSyntax) add_subdirectory(LibSystem) add_subdirectory(LibTest) add_subdirectory(LibTextCodec) -add_subdirectory(LibThread) +add_subdirectory(LibThreading) add_subdirectory(LibTLS) add_subdirectory(LibTTF) add_subdirectory(LibVT) diff --git a/Userland/Libraries/LibC/malloc.cpp b/Userland/Libraries/LibC/malloc.cpp index 43519cf296..820c117ef3 100644 --- a/Userland/Libraries/LibC/malloc.cpp +++ b/Userland/Libraries/LibC/malloc.cpp @@ -9,7 +9,7 @@ #include <AK/ScopedValueRollback.h> #include <AK/Vector.h> #include <LibELF/AuxiliaryVector.h> -#include <LibThread/Lock.h> +#include <LibThreading/Lock.h> #include <assert.h> #include <errno.h> #include <mallocdefs.h> @@ -27,10 +27,10 @@ #define PAGE_ROUND_UP(x) ((((size_t)(x)) + PAGE_SIZE - 1) & (~(PAGE_SIZE - 1))) -static LibThread::Lock& malloc_lock() +static Threading::Lock& malloc_lock() { - static u32 lock_storage[sizeof(LibThread::Lock) / sizeof(u32)]; - return *reinterpret_cast<LibThread::Lock*>(&lock_storage); + static u32 lock_storage[sizeof(Threading::Lock) / sizeof(u32)]; + return *reinterpret_cast<Threading::Lock*>(&lock_storage); } constexpr size_t number_of_chunked_blocks_to_keep_around_per_size_class = 4; @@ -158,7 +158,7 @@ enum class CallerWillInitializeMemory { static void* malloc_impl(size_t size, CallerWillInitializeMemory caller_will_initialize_memory) { - LibThread::Locker locker(malloc_lock()); + Threading::Locker locker(malloc_lock()); if (s_log_malloc) dbgln("LibC: malloc({})", size); @@ -279,7 +279,7 @@ static void free_impl(void* ptr) g_malloc_stats.number_of_free_calls++; - LibThread::Locker locker(malloc_lock()); + Threading::Locker locker(malloc_lock()); void* block_base = (void*)((FlatPtr)ptr & ChunkedBlock::ChunkedBlock::block_mask); size_t magic = *(size_t*)block_base; @@ -381,7 +381,7 @@ size_t malloc_size(void* ptr) { if (!ptr) return 0; - LibThread::Locker locker(malloc_lock()); + Threading::Locker locker(malloc_lock()); void* page_base = (void*)((FlatPtr)ptr & ChunkedBlock::block_mask); auto* header = (const CommonHeader*)page_base; auto size = header->m_size; @@ -406,7 +406,7 @@ void* realloc(void* ptr, size_t size) if (!size) return nullptr; - LibThread::Locker locker(malloc_lock()); + Threading::Locker locker(malloc_lock()); auto existing_allocation_size = malloc_size(ptr); if (size <= existing_allocation_size) { @@ -423,7 +423,7 @@ void* realloc(void* ptr, size_t size) void __malloc_init() { - new (&malloc_lock()) LibThread::Lock(); + new (&malloc_lock()) Threading::Lock(); s_in_userspace_emulator = (int)syscall(SC_emuctl, 0) != -ENOSYS; if (s_in_userspace_emulator) { diff --git a/Userland/Libraries/LibCore/EventLoop.cpp b/Userland/Libraries/LibCore/EventLoop.cpp index 7d95890768..23dabfc764 100644 --- a/Userland/Libraries/LibCore/EventLoop.cpp +++ b/Userland/Libraries/LibCore/EventLoop.cpp @@ -21,7 +21,7 @@ #include <LibCore/LocalSocket.h> #include <LibCore/Notifier.h> #include <LibCore/Object.h> -#include <LibThread/Lock.h> +#include <LibThreading/Lock.h> #include <errno.h> #include <fcntl.h> #include <signal.h> @@ -54,7 +54,7 @@ struct EventLoopTimer { }; struct EventLoop::Private { - LibThread::Lock lock; + Threading::Lock lock; }; static EventLoop* s_main_event_loop; @@ -372,7 +372,7 @@ void EventLoop::pump(WaitMode mode) decltype(m_queued_events) events; { - LibThread::Locker locker(m_private->lock); + Threading::Locker locker(m_private->lock); events = move(m_queued_events); } @@ -401,7 +401,7 @@ void EventLoop::pump(WaitMode mode) } if (m_exit_requested) { - LibThread::Locker locker(m_private->lock); + Threading::Locker locker(m_private->lock); dbgln_if(EVENTLOOP_DEBUG, "Core::EventLoop: Exit requested. Rejigging {} events.", events.size() - i); decltype(m_queued_events) new_event_queue; new_event_queue.ensure_capacity(m_queued_events.size() + events.size()); @@ -416,7 +416,7 @@ void EventLoop::pump(WaitMode mode) void EventLoop::post_event(Object& receiver, NonnullOwnPtr<Event>&& event) { - LibThread::Locker lock(m_private->lock); + Threading::Locker lock(m_private->lock); dbgln_if(EVENTLOOP_DEBUG, "Core::EventLoop::post_event: ({}) << receivier={}, event={}", m_queued_events.size(), receiver, event); m_queued_events.empend(receiver, move(event)); } @@ -600,7 +600,7 @@ retry: bool queued_events_is_empty; { - LibThread::Locker locker(m_private->lock); + Threading::Locker locker(m_private->lock); queued_events_is_empty = m_queued_events.is_empty(); } diff --git a/Userland/Libraries/LibGUI/CMakeLists.txt b/Userland/Libraries/LibGUI/CMakeLists.txt index 65362b1184..434f81cdde 100644 --- a/Userland/Libraries/LibGUI/CMakeLists.txt +++ b/Userland/Libraries/LibGUI/CMakeLists.txt @@ -117,4 +117,4 @@ set(GENERATED_SOURCES ) serenity_lib(LibGUI gui) -target_link_libraries(LibGUI LibCore LibGfx LibIPC LibThread LibRegex LibSyntax) +target_link_libraries(LibGUI LibCore LibGfx LibIPC LibThreading LibRegex LibSyntax) diff --git a/Userland/Libraries/LibGUI/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp index 3a57f0761f..dd83c7204b 100644 --- a/Userland/Libraries/LibGUI/FileSystemModel.cpp +++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp @@ -16,7 +16,7 @@ #include <LibGUI/FileSystemModel.h> #include <LibGUI/Painter.h> #include <LibGfx/Bitmap.h> -#include <LibThread/BackgroundAction.h> +#include <LibThreading/BackgroundAction.h> #include <grp.h> #include <pwd.h> #include <stdio.h> @@ -571,7 +571,7 @@ bool FileSystemModel::fetch_thumbnail_for(const Node& node) auto weak_this = make_weak_ptr(); - LibThread::BackgroundAction<RefPtr<Gfx::Bitmap>>::create( + Threading::BackgroundAction<RefPtr<Gfx::Bitmap>>::create( [path] { return render_thumbnail(path); }, diff --git a/Userland/Libraries/LibThread/CMakeLists.txt b/Userland/Libraries/LibThread/CMakeLists.txt deleted file mode 100644 index 6bfce1c060..0000000000 --- a/Userland/Libraries/LibThread/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -set(SOURCES - BackgroundAction.cpp - Thread.cpp -) - -serenity_lib(LibThread thread) -target_link_libraries(LibThread LibC LibCore LibPthread) diff --git a/Userland/Libraries/LibThread/BackgroundAction.cpp b/Userland/Libraries/LibThreading/BackgroundAction.cpp index 2afea64ea4..7e95cec977 100644 --- a/Userland/Libraries/LibThread/BackgroundAction.cpp +++ b/Userland/Libraries/LibThreading/BackgroundAction.cpp @@ -5,19 +5,19 @@ */ #include <AK/Queue.h> -#include <LibThread/BackgroundAction.h> -#include <LibThread/Lock.h> -#include <LibThread/Thread.h> +#include <LibThreading/BackgroundAction.h> +#include <LibThreading/Lock.h> +#include <LibThreading/Thread.h> -static LibThread::Lockable<Queue<Function<void()>>>* s_all_actions; -static LibThread::Thread* s_background_thread; +static Threading::Lockable<Queue<Function<void()>>>* s_all_actions; +static Threading::Thread* s_background_thread; static intptr_t background_thread_func() { while (true) { Function<void()> work_item; { - LibThread::Locker locker(s_all_actions->lock()); + Threading::Locker locker(s_all_actions->lock()); if (!s_all_actions->resource().is_empty()) work_item = s_all_actions->resource().dequeue(); @@ -33,20 +33,20 @@ static intptr_t background_thread_func() static void init() { - s_all_actions = new LibThread::Lockable<Queue<Function<void()>>>(); - s_background_thread = &LibThread::Thread::construct(background_thread_func).leak_ref(); + s_all_actions = new Threading::Lockable<Queue<Function<void()>>>(); + s_background_thread = &Threading::Thread::construct(background_thread_func).leak_ref(); s_background_thread->set_name("Background thread"); s_background_thread->start(); } -LibThread::Lockable<Queue<Function<void()>>>& LibThread::BackgroundActionBase::all_actions() +Threading::Lockable<Queue<Function<void()>>>& Threading::BackgroundActionBase::all_actions() { if (s_all_actions == nullptr) init(); return *s_all_actions; } -LibThread::Thread& LibThread::BackgroundActionBase::background_thread() +Threading::Thread& Threading::BackgroundActionBase::background_thread() { if (s_background_thread == nullptr) init(); diff --git a/Userland/Libraries/LibThread/BackgroundAction.h b/Userland/Libraries/LibThreading/BackgroundAction.h index 6770cebaae..9c40873a3c 100644 --- a/Userland/Libraries/LibThread/BackgroundAction.h +++ b/Userland/Libraries/LibThreading/BackgroundAction.h @@ -13,10 +13,10 @@ #include <LibCore/Event.h> #include <LibCore/EventLoop.h> #include <LibCore/Object.h> -#include <LibThread/Lock.h> -#include <LibThread/Thread.h> +#include <LibThreading/Lock.h> +#include <LibThreading/Thread.h> -namespace LibThread { +namespace Threading { template<typename Result> class BackgroundAction; diff --git a/Userland/Libraries/LibThreading/CMakeLists.txt b/Userland/Libraries/LibThreading/CMakeLists.txt new file mode 100644 index 0000000000..db9fc4c6ff --- /dev/null +++ b/Userland/Libraries/LibThreading/CMakeLists.txt @@ -0,0 +1,7 @@ +set(SOURCES + BackgroundAction.cpp + Thread.cpp +) + +serenity_lib(LibThreading threading) +target_link_libraries(LibThreading LibC LibCore LibPthread) diff --git a/Userland/Libraries/LibThread/Lock.h b/Userland/Libraries/LibThreading/Lock.h index 165082d708..9cc4bf9b2a 100644 --- a/Userland/Libraries/LibThread/Lock.h +++ b/Userland/Libraries/LibThreading/Lock.h @@ -16,7 +16,7 @@ # include <pthread.h> #endif -namespace LibThread { +namespace Threading { class Lock { public: diff --git a/Userland/Libraries/LibThread/Thread.cpp b/Userland/Libraries/LibThreading/Thread.cpp index db3aeb0022..71c6c4f45e 100644 --- a/Userland/Libraries/LibThread/Thread.cpp +++ b/Userland/Libraries/LibThreading/Thread.cpp @@ -4,12 +4,12 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <LibThread/Thread.h> +#include <LibThreading/Thread.h> #include <pthread.h> #include <string.h> #include <unistd.h> -LibThread::Thread::Thread(Function<intptr_t()> action, StringView thread_name) +Threading::Thread::Thread(Function<intptr_t()> action, StringView thread_name) : Core::Object(nullptr) , m_action(move(action)) , m_thread_name(thread_name.is_null() ? "" : thread_name) @@ -18,7 +18,7 @@ LibThread::Thread::Thread(Function<intptr_t()> action, StringView thread_name) register_property("tid", [&] { return JsonValue { m_tid }; }); } -LibThread::Thread::~Thread() +Threading::Thread::~Thread() { if (m_tid) { dbgln("Destroying thread \"{}\"({}) while it is still running!", m_thread_name, m_tid); @@ -26,7 +26,7 @@ LibThread::Thread::~Thread() } } -void LibThread::Thread::start() +void Threading::Thread::start() { int rc = pthread_create( &m_tid, diff --git a/Userland/Libraries/LibThread/Thread.h b/Userland/Libraries/LibThreading/Thread.h index 255d8f8903..d04fba6a54 100644 --- a/Userland/Libraries/LibThread/Thread.h +++ b/Userland/Libraries/LibThreading/Thread.h @@ -13,7 +13,7 @@ #include <LibCore/Object.h> #include <pthread.h> -namespace LibThread { +namespace Threading { TYPEDEF_DISTINCT_ORDERED_ID(intptr_t, ThreadError); diff --git a/Userland/Services/AudioServer/CMakeLists.txt b/Userland/Services/AudioServer/CMakeLists.txt index 9c71197b62..e82b4732b0 100644 --- a/Userland/Services/AudioServer/CMakeLists.txt +++ b/Userland/Services/AudioServer/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_bin(AudioServer) -target_link_libraries(AudioServer LibCore LibThread LibIPC) +target_link_libraries(AudioServer LibCore LibThreading LibIPC) diff --git a/Userland/Services/AudioServer/Mixer.cpp b/Userland/Services/AudioServer/Mixer.cpp index a2e2a9c424..8e5d8b785b 100644 --- a/Userland/Services/AudioServer/Mixer.cpp +++ b/Userland/Services/AudioServer/Mixer.cpp @@ -16,7 +16,7 @@ namespace AudioServer { Mixer::Mixer() : m_device(Core::File::construct("/dev/audio", this)) - , m_sound_thread(LibThread::Thread::construct( + , m_sound_thread(Threading::Thread::construct( [this] { mix(); return 0; diff --git a/Userland/Services/AudioServer/Mixer.h b/Userland/Services/AudioServer/Mixer.h index 4b12683f50..c3af89158d 100644 --- a/Userland/Services/AudioServer/Mixer.h +++ b/Userland/Services/AudioServer/Mixer.h @@ -16,8 +16,8 @@ #include <AK/WeakPtr.h> #include <LibAudio/Buffer.h> #include <LibCore/File.h> -#include <LibThread/Lock.h> -#include <LibThread/Thread.h> +#include <LibThreading/Lock.h> +#include <LibThreading/Thread.h> namespace AudioServer { @@ -112,7 +112,7 @@ private: RefPtr<Core::File> m_device; - NonnullRefPtr<LibThread::Thread> m_sound_thread; + NonnullRefPtr<Threading::Thread> m_sound_thread; bool m_muted { false }; int m_main_volume { 100 }; diff --git a/Userland/Services/WindowServer/CMakeLists.txt b/Userland/Services/WindowServer/CMakeLists.txt index f5aed72499..533e004107 100644 --- a/Userland/Services/WindowServer/CMakeLists.txt +++ b/Userland/Services/WindowServer/CMakeLists.txt @@ -28,5 +28,5 @@ set(SOURCES ) serenity_bin(WindowServer) -target_link_libraries(WindowServer LibCore LibGfx LibThread LibPthread LibIPC) +target_link_libraries(WindowServer LibCore LibGfx LibThreading LibIPC) serenity_install_headers(Services/WindowServer) diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp index 806ddca403..0d0b649530 100644 --- a/Userland/Services/WindowServer/Compositor.cpp +++ b/Userland/Services/WindowServer/Compositor.cpp @@ -18,7 +18,7 @@ #include <LibGfx/Font.h> #include <LibGfx/Painter.h> #include <LibGfx/StylePainter.h> -#include <LibThread/BackgroundAction.h> +#include <LibThreading/BackgroundAction.h> namespace WindowServer { @@ -609,7 +609,7 @@ bool Compositor::set_wallpaper_mode(const String& mode) bool Compositor::set_wallpaper(const String& path, Function<void(bool)>&& callback) { - LibThread::BackgroundAction<RefPtr<Gfx::Bitmap>>::create( + Threading::BackgroundAction<RefPtr<Gfx::Bitmap>>::create( [path] { return Gfx::Bitmap::load_from_file(path); }, diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index 4951153865..dd63e4dce6 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -50,7 +50,7 @@ target_link_libraries(tar LibArchive LibCompress) target_link_libraries(telws LibProtocol LibLine) target_link_libraries(test-crypto LibCrypto LibTLS LibLine) target_link_libraries(test-fuzz LibCore LibGemini LibGfx LibHTTP LibIPC LibJS LibMarkdown LibShell) -target_link_libraries(test-pthread LibThread) +target_link_libraries(test-pthread LibThreading) target_link_libraries(tt LibPthread) target_link_libraries(unzip LibArchive LibCompress) target_link_libraries(zip LibArchive LibCompress LibCrypto) diff --git a/Userland/Utilities/test-pthread.cpp b/Userland/Utilities/test-pthread.cpp index d40adee8a2..559ece4a46 100644 --- a/Userland/Utilities/test-pthread.cpp +++ b/Userland/Utilities/test-pthread.cpp @@ -6,7 +6,7 @@ #include <AK/Assertions.h> #include <AK/NonnullRefPtrVector.h> -#include <LibThread/Thread.h> +#include <LibThreading/Thread.h> #include <pthread.h> #include <unistd.h> @@ -17,10 +17,10 @@ static void test_once() static Vector<int> v; v.clear(); pthread_once_t once = PTHREAD_ONCE_INIT; - NonnullRefPtrVector<LibThread::Thread, threads_count> threads; + NonnullRefPtrVector<Threading::Thread, threads_count> threads; for (size_t i = 0; i < threads_count; i++) { - threads.append(LibThread::Thread::construct([&] { + threads.append(Threading::Thread::construct([&] { return pthread_once(&once, [] { v.append(35); sleep(1); |