mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-18 08:20:44 +00:00
LibThreading: Build on Windows
This commit is contained in:
parent
e2b6ab4a69
commit
85da489f39
Notes:
github-actions[bot]
2024-12-09 00:20:34 +00:00
Author: https://github.com/stasoid
Commit: 85da489f39
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2618
Reviewed-by: https://github.com/ADKaster ✅
4 changed files with 17 additions and 5 deletions
|
@ -9,7 +9,6 @@
|
||||||
#include <LibThreading/BackgroundAction.h>
|
#include <LibThreading/BackgroundAction.h>
|
||||||
#include <LibThreading/Mutex.h>
|
#include <LibThreading/Mutex.h>
|
||||||
#include <LibThreading/Thread.h>
|
#include <LibThreading/Thread.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
static pthread_mutex_t s_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t s_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static pthread_cond_t s_condition = PTHREAD_COND_INITIALIZER;
|
static pthread_cond_t s_condition = PTHREAD_COND_INITIALIZER;
|
||||||
|
|
|
@ -5,3 +5,9 @@ set(SOURCES
|
||||||
|
|
||||||
serenity_lib(LibThreading threading)
|
serenity_lib(LibThreading threading)
|
||||||
target_link_libraries(LibThreading PRIVATE LibCore)
|
target_link_libraries(LibThreading PRIVATE LibCore)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
find_package(pthread REQUIRED)
|
||||||
|
target_include_directories(LibThreading PRIVATE ${PTHREAD_INCLUDE_DIR})
|
||||||
|
target_link_libraries(LibThreading PUBLIC ${PTHREAD_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
|
@ -5,9 +5,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibThreading/Thread.h>
|
#include <LibThreading/Thread.h>
|
||||||
#include <pthread.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
namespace Threading {
|
namespace Threading {
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
private:
|
private:
|
||||||
explicit Thread(ESCAPING Function<intptr_t()> action, StringView thread_name = {});
|
explicit Thread(ESCAPING Function<intptr_t()> action, StringView thread_name = {});
|
||||||
Function<intptr_t()> m_action;
|
Function<intptr_t()> m_action;
|
||||||
pthread_t m_tid { 0 };
|
pthread_t m_tid {};
|
||||||
ByteString m_thread_name;
|
ByteString m_thread_name;
|
||||||
Atomic<ThreadState> m_state { ThreadState::Startable };
|
Atomic<ThreadState> m_state { ThreadState::Startable };
|
||||||
};
|
};
|
||||||
|
@ -108,6 +108,16 @@ Result<T, ThreadError> Thread::join()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef AK_OS_WINDOWS
|
||||||
|
template<>
|
||||||
|
struct AK::Formatter<pthread_t> : AK::Formatter<FormatString> {
|
||||||
|
ErrorOr<void> format(FormatBuilder& builder, pthread_t const& tid)
|
||||||
|
{
|
||||||
|
return Formatter<FormatString>::format(builder, "{}"sv, pthread_getw32threadid_np(tid));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct AK::Formatter<Threading::Thread> : AK::Formatter<FormatString> {
|
struct AK::Formatter<Threading::Thread> : AK::Formatter<FormatString> {
|
||||||
ErrorOr<void> format(FormatBuilder& builder, Threading::Thread const& thread)
|
ErrorOr<void> format(FormatBuilder& builder, Threading::Thread const& thread)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue