mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibThreading: Rename Lock => Mutex
This commit is contained in:
parent
ce5d2b4f16
commit
b8a204c5b9
Notes:
sideshowbarker
2024-07-18 10:01:01 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b8a204c5b9c
8 changed files with 37 additions and 37 deletions
|
@ -16,7 +16,7 @@
|
|||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
#include <LibThreading/Lock.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace Assistant {
|
||||
|
@ -26,7 +26,7 @@ struct AppState {
|
|||
NonnullRefPtrVector<Result> results;
|
||||
size_t visible_result_count { 0 };
|
||||
|
||||
Threading::Lock lock;
|
||||
Threading::Mutex lock;
|
||||
String last_query;
|
||||
};
|
||||
|
||||
|
@ -143,7 +143,7 @@ private:
|
|||
void did_receive_results(String const& query, NonnullRefPtrVector<Result> const& results)
|
||||
{
|
||||
{
|
||||
Threading::Locker db_locker(m_lock);
|
||||
Threading::MutexLocker db_locker(m_mutex);
|
||||
auto it = m_result_cache.find(query);
|
||||
if (it == m_result_cache.end()) {
|
||||
m_result_cache.set(query, {});
|
||||
|
@ -160,7 +160,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
Threading::Locker state_locker(m_state.lock);
|
||||
Threading::MutexLocker state_locker(m_state.lock);
|
||||
auto new_results = m_result_cache.find(m_state.last_query);
|
||||
if (new_results == m_result_cache.end())
|
||||
return;
|
||||
|
@ -181,7 +181,7 @@ private:
|
|||
|
||||
NonnullOwnPtrVector<Provider> m_providers;
|
||||
|
||||
Threading::Lock m_lock;
|
||||
Threading::Mutex m_mutex;
|
||||
HashMap<String, NonnullRefPtrVector<Result>> m_result_cache;
|
||||
};
|
||||
|
||||
|
@ -223,7 +223,7 @@ int main(int argc, char** argv)
|
|||
|
||||
text_box.on_change = [&]() {
|
||||
{
|
||||
Threading::Locker locker(app_state.lock);
|
||||
Threading::MutexLocker locker(app_state.lock);
|
||||
if (app_state.last_query == text_box.text())
|
||||
return;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <AK/LexicalPath.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibDebug/DebugSession.h>
|
||||
#include <LibThreading/Lock.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
#include <LibThreading/Thread.h>
|
||||
|
||||
namespace HackStudio {
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
#include <LibGUI/Window.h>
|
||||
#include <LibGfx/FontDatabase.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
#include <LibThreading/Lock.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
#include <LibThreading/Thread.h>
|
||||
#include <LibVT/TerminalWidget.h>
|
||||
#include <fcntl.h>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <AK/ScopedValueRollback.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibELF/AuxiliaryVector.h>
|
||||
#include <LibThreading/Lock.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <mallocdefs.h>
|
||||
|
@ -24,10 +24,10 @@
|
|||
|
||||
#define RECYCLE_BIG_ALLOCATIONS
|
||||
|
||||
static Threading::Lock& malloc_lock()
|
||||
static Threading::Mutex& malloc_lock()
|
||||
{
|
||||
alignas(Threading::Lock) static u8 lock_storage[sizeof(Threading::Lock)];
|
||||
return *reinterpret_cast<Threading::Lock*>(lock_storage);
|
||||
alignas(Threading::Mutex) static u8 lock_storage[sizeof(Threading::Mutex)];
|
||||
return *reinterpret_cast<Threading::Mutex*>(lock_storage);
|
||||
}
|
||||
|
||||
constexpr size_t number_of_hot_chunked_blocks_to_keep_around = 16;
|
||||
|
@ -167,7 +167,7 @@ enum class CallerWillInitializeMemory {
|
|||
|
||||
static void* malloc_impl(size_t size, CallerWillInitializeMemory caller_will_initialize_memory)
|
||||
{
|
||||
Threading::Locker locker(malloc_lock());
|
||||
Threading::MutexLocker locker(malloc_lock());
|
||||
|
||||
if (s_log_malloc)
|
||||
dbgln("LibC: malloc({})", size);
|
||||
|
@ -304,7 +304,7 @@ static void free_impl(void* ptr)
|
|||
|
||||
g_malloc_stats.number_of_free_calls++;
|
||||
|
||||
Threading::Locker locker(malloc_lock());
|
||||
Threading::MutexLocker locker(malloc_lock());
|
||||
|
||||
void* block_base = (void*)((FlatPtr)ptr & ChunkedBlock::ChunkedBlock::block_mask);
|
||||
size_t magic = *(size_t*)block_base;
|
||||
|
@ -413,7 +413,7 @@ size_t malloc_size(void* ptr)
|
|||
{
|
||||
if (!ptr)
|
||||
return 0;
|
||||
Threading::Locker locker(malloc_lock());
|
||||
Threading::MutexLocker locker(malloc_lock());
|
||||
void* page_base = (void*)((FlatPtr)ptr & ChunkedBlock::block_mask);
|
||||
auto* header = (const CommonHeader*)page_base;
|
||||
auto size = header->m_size;
|
||||
|
@ -440,7 +440,7 @@ void* realloc(void* ptr, size_t size)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Threading::Locker locker(malloc_lock());
|
||||
Threading::MutexLocker locker(malloc_lock());
|
||||
auto existing_allocation_size = malloc_size(ptr);
|
||||
|
||||
if (size <= existing_allocation_size) {
|
||||
|
@ -457,7 +457,7 @@ void* realloc(void* ptr, size_t size)
|
|||
|
||||
void __malloc_init()
|
||||
{
|
||||
new (&malloc_lock()) Threading::Lock();
|
||||
new (&malloc_lock()) Threading::Mutex();
|
||||
|
||||
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 <LibThreading/Lock.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
|
@ -54,7 +54,7 @@ struct EventLoopTimer {
|
|||
};
|
||||
|
||||
struct EventLoop::Private {
|
||||
Threading::Lock lock;
|
||||
Threading::Mutex lock;
|
||||
};
|
||||
|
||||
static EventLoop* s_main_event_loop;
|
||||
|
@ -370,7 +370,7 @@ void EventLoop::pump(WaitMode mode)
|
|||
|
||||
decltype(m_queued_events) events;
|
||||
{
|
||||
Threading::Locker locker(m_private->lock);
|
||||
Threading::MutexLocker locker(m_private->lock);
|
||||
events = move(m_queued_events);
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ void EventLoop::pump(WaitMode mode)
|
|||
}
|
||||
|
||||
if (m_exit_requested) {
|
||||
Threading::Locker locker(m_private->lock);
|
||||
Threading::MutexLocker 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());
|
||||
|
@ -414,7 +414,7 @@ void EventLoop::pump(WaitMode mode)
|
|||
|
||||
void EventLoop::post_event(Object& receiver, NonnullOwnPtr<Event>&& event)
|
||||
{
|
||||
Threading::Locker lock(m_private->lock);
|
||||
Threading::MutexLocker 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));
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ retry:
|
|||
|
||||
bool queued_events_is_empty;
|
||||
{
|
||||
Threading::Locker locker(m_private->lock);
|
||||
Threading::MutexLocker locker(m_private->lock);
|
||||
queued_events_is_empty = m_queued_events.is_empty();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <AK/Queue.h>
|
||||
#include <LibThreading/BackgroundAction.h>
|
||||
#include <LibThreading/Lock.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
#include <LibThreading/Thread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
namespace Threading {
|
||||
|
||||
class Lock {
|
||||
class Mutex {
|
||||
public:
|
||||
Lock()
|
||||
Mutex()
|
||||
{
|
||||
#ifndef __serenity__
|
||||
pthread_mutexattr_t attr;
|
||||
|
@ -23,7 +23,7 @@ public:
|
|||
pthread_mutex_init(&m_mutex, &attr);
|
||||
#endif
|
||||
}
|
||||
~Lock() { }
|
||||
~Mutex() { }
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
|
@ -36,27 +36,27 @@ private:
|
|||
#endif
|
||||
};
|
||||
|
||||
class Locker {
|
||||
class MutexLocker {
|
||||
public:
|
||||
ALWAYS_INLINE explicit Locker(Lock& l)
|
||||
: m_lock(l)
|
||||
ALWAYS_INLINE explicit MutexLocker(Mutex& mutex)
|
||||
: m_mutex(mutex)
|
||||
{
|
||||
lock();
|
||||
}
|
||||
ALWAYS_INLINE ~Locker() { unlock(); }
|
||||
ALWAYS_INLINE void unlock() { m_lock.unlock(); }
|
||||
ALWAYS_INLINE void lock() { m_lock.lock(); }
|
||||
ALWAYS_INLINE ~MutexLocker() { unlock(); }
|
||||
ALWAYS_INLINE void unlock() { m_mutex.unlock(); }
|
||||
ALWAYS_INLINE void lock() { m_mutex.lock(); }
|
||||
|
||||
private:
|
||||
Lock& m_lock;
|
||||
Mutex& m_mutex;
|
||||
};
|
||||
|
||||
ALWAYS_INLINE void Lock::lock()
|
||||
ALWAYS_INLINE void Mutex::lock()
|
||||
{
|
||||
pthread_mutex_lock(&m_mutex);
|
||||
}
|
||||
|
||||
inline void Lock::unlock()
|
||||
ALWAYS_INLINE void Mutex::unlock()
|
||||
{
|
||||
pthread_mutex_unlock(&m_mutex);
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
#include <AK/WeakPtr.h>
|
||||
#include <LibAudio/Buffer.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibThreading/Lock.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
#include <LibThreading/Thread.h>
|
||||
|
||||
namespace AudioServer {
|
||||
|
|
Loading…
Reference in a new issue