Skip to content

Commit cffa1ca

Browse files
committed
Remove pthread-win32 dependency
1 parent d38fc31 commit cffa1ca

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

3rdparty/pthread-win32

Lines changed: 0 additions & 1 deletion
This file was deleted.

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ add_library(ur_client_library::urcl ALIAS urcl)
5858

5959
if(MSVC)
6060
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/endian)
61-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/pthread-win32)
62-
target_link_libraries(urcl pthreadVCE3)
6361
target_link_libraries(urcl ws2_32)
6462
else()
6563
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")

include/ur_client_library/helpers.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,38 @@
2929
#ifndef UR_CLIENT_LIBRARY_HELPERS_H_INCLUDED
3030
#define UR_CLIENT_LIBRARY_HELPERS_H_INCLUDED
3131

32+
33+
#ifdef _WIN32
34+
35+
#define NOMINMAX
36+
#define WIN32_LEAN_AND_MEAN
37+
#include <Windows.h>
38+
39+
#ifdef ERROR
40+
#undef ERROR
41+
#endif // ERROR
42+
43+
#define SCHED_FIFO (1)
44+
45+
typedef HANDLE pthread_t;
46+
47+
48+
static inline pthread_t pthread_self()
49+
{
50+
return ::GetCurrentThread();
51+
}
52+
53+
static inline int sched_get_priority_max(int policy)
54+
{
55+
return THREAD_PRIORITY_TIME_CRITICAL;
56+
}
57+
58+
#else // _WIN32
59+
3260
#include <pthread.h>
3361

62+
#endif // _WIN32
63+
3464
namespace urcl
3565
{
3666
bool setFiFoScheduling(pthread_t& thread, const int priority);

src/helpers.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ namespace urcl
3737
{
3838
bool setFiFoScheduling(pthread_t& thread, const int priority)
3939
{
40+
#ifdef _WIN32
41+
return ::SetThreadPriority(thread, priority);
42+
#else // _WIN32
4043
struct sched_param params;
4144
params.sched_priority = priority;
4245
int ret = pthread_setschedparam(thread, SCHED_FIFO, &params);
@@ -88,5 +91,6 @@ bool setFiFoScheduling(pthread_t& thread, const int priority)
8891
}
8992
}
9093
return true;
94+
#endif
9195
}
9296
} // namespace urcl

0 commit comments

Comments
 (0)