mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +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: https://github.com/LadybirdBrowser/ladybird/commit/85da489f390 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/Mutex.h>
|
||||
#include <LibThreading/Thread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static pthread_mutex_t s_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t s_condition = PTHREAD_COND_INITIALIZER;
|
||||
|
|
|
@ -5,3 +5,9 @@ set(SOURCES
|
|||
|
||||
serenity_lib(LibThreading threading)
|
||||
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 <pthread.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace Threading {
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
private:
|
||||
explicit Thread(ESCAPING Function<intptr_t()> action, StringView thread_name = {});
|
||||
Function<intptr_t()> m_action;
|
||||
pthread_t m_tid { 0 };
|
||||
pthread_t m_tid {};
|
||||
ByteString m_thread_name;
|
||||
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<>
|
||||
struct AK::Formatter<Threading::Thread> : AK::Formatter<FormatString> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Threading::Thread const& thread)
|
||||
|
|
Loading…
Add table
Reference in a new issue