mirror of
https://github.com/RGBCube/serenity
synced 2025-08-10 16:47:35 +00:00
Userland: Rename LibThread => LibThreading
Also rename the "LibThread" namespace to "Threading"
This commit is contained in:
parent
5729b4e9a5
commit
b5d73c834f
25 changed files with 69 additions and 69 deletions
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
set(SOURCES
|
||||
BackgroundAction.cpp
|
||||
Thread.cpp
|
||||
)
|
||||
|
||||
serenity_lib(LibThread thread)
|
||||
target_link_libraries(LibThread LibC LibCore LibPthread)
|
|
@ -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();
|
|
@ -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;
|
7
Userland/Libraries/LibThreading/CMakeLists.txt
Normal file
7
Userland/Libraries/LibThreading/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
set(SOURCES
|
||||
BackgroundAction.cpp
|
||||
Thread.cpp
|
||||
)
|
||||
|
||||
serenity_lib(LibThreading threading)
|
||||
target_link_libraries(LibThreading LibC LibCore LibPthread)
|
|
@ -16,7 +16,7 @@
|
|||
# include <pthread.h>
|
||||
#endif
|
||||
|
||||
namespace LibThread {
|
||||
namespace Threading {
|
||||
|
||||
class Lock {
|
||||
public:
|
|
@ -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,
|
|
@ -13,7 +13,7 @@
|
|||
#include <LibCore/Object.h>
|
||||
#include <pthread.h>
|
||||
|
||||
namespace LibThread {
|
||||
namespace Threading {
|
||||
|
||||
TYPEDEF_DISTINCT_ORDERED_ID(intptr_t, ThreadError);
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue