Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
*******************************************************************************

=== 1.0.37 ===

* Implemented immediate wake-up of a thread sleeping in ipc::Thread::sleep()
on ipc::Thread::cancel(); the sleep is no longer split into 100 ms intervals.
* The ipc/Thread.h header no longer includes platform headers (Windows or
pthread); the platform-specific state of ipc::Thread is kept in Thread.cpp.

=== 1.0.36 ===
* Updated build scripts.
Expand Down
32 changes: 13 additions & 19 deletions include/lsp-plug.in/ipc/Thread.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
* (C) 2025 Vladimir Sadovnikov <sadko4u@gmail.com>
* Copyright (C) 2026 Linux Studio Plugins Project <https://lsp-plug.in/>
* (C) 2026 Vladimir Sadovnikov <sadko4u@gmail.com>
*
* This file is part of lsp-runtime-lib
* Created on: 25 февр. 2019 г.
Expand All @@ -27,12 +27,6 @@
#include <lsp-plug.in/common/types.h>
#include <lsp-plug.in/common/status.h>

#if defined(PLATFORM_WINDOWS)
#include <processthreadsapi.h>
#else
#include <pthread.h>
#endif /* PLATFORM_WINDOWS */

#include <lsp-plug.in/ipc/IRunnable.h>
#include <lsp-plug.in/runtime/system.h>

Expand All @@ -59,6 +53,11 @@ namespace lsp

constexpr thread_id_t INVALID_THREAD_ID = 0;

namespace detail
{
struct thread_impl_t;
} /* namespace detail */

/**
* Thread class
*/
Expand All @@ -81,31 +80,26 @@ namespace lsp
volatile bool bCancelled;
volatile status_t nResult;

#if defined(PLATFORM_WINDOWS)
HANDLE hThread; // Windows threads
#else
pthread_t hThread; // POSIX threads
#endif /* PLATFORM_WINDOWS */
detail::thread_impl_t *pImpl; // Platform-specific thread handle and cancellation wake-up

protected:
binding_t sBinding;

private:
#if defined(PLATFORM_WINDOWS)
static DWORD WINAPI thread_launcher(_In_ LPVOID lpParameter);
#else
static void *thread_launcher(void *arg);
#endif /* PLATFORM_WINDOWS */
friend struct detail::thread_impl_t;

Thread(const Thread &src); // Deny copying
Thread & operator = (const Thread &src); // Deny copying

void init_impl();

public:
explicit Thread();
explicit Thread(thread_proc_t proc);
explicit Thread(thread_proc_t proc, void *arg);
explicit Thread(IRunnable *runnable);

virtual ~Thread();
virtual ~Thread(); // The thread must be joined before it is destroyed

public:
/**
Expand Down
Loading