File tree 15 files changed +11
-118
lines changed
15 files changed +11
-118
lines changed Original file line number Diff line number Diff line change 49
49
using thread_id = ::thrd_t ;
50
50
51
51
inline thread_id thread_get_current () { return ::thrd_current (); }
52
- thread_id thread_get_main ();
53
52
bool thread_is_main ();
54
53
inline bool threads_same (thread_id a, thread_id b) {
55
54
return ::thrd_equal (a, b);
Original file line number Diff line number Diff line change @@ -32,8 +32,7 @@ using thread_id = ::pthread_t;
32
32
33
33
inline thread_id thread_get_current () { return ::pthread_self (); }
34
34
35
- thread_id thread_get_main ();
36
- bool thread_is_main ();
35
+ inline bool thread_is_main () { return pthread_main_np (); }
37
36
38
37
inline bool threads_same (thread_id a, thread_id b) {
39
38
return ::pthread_equal (a, b);
Original file line number Diff line number Diff line change @@ -55,7 +55,6 @@ using thread_id = ::pthread_t;
55
55
56
56
inline thread_id thread_get_current () { return ::pthread_self (); }
57
57
58
- thread_id thread_get_main ();
59
58
bool thread_is_main ();
60
59
61
60
inline bool threads_same (thread_id a, thread_id b) {
Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ namespace threading_impl {
25
25
using thread_id = unsigned ;
26
26
27
27
inline thread_id thread_get_current () { return 0 ; }
28
- inline thread_id thread_get_main () { return 0 ; }
29
28
inline bool thread_is_main () { return true ; }
30
29
inline bool threads_same (thread_id a, thread_id b) { return a == b; }
31
30
Original file line number Diff line number Diff line change @@ -54,7 +54,6 @@ using thread_id = ::pthread_t;
54
54
55
55
inline thread_id thread_get_current () { return ::pthread_self (); }
56
56
57
- thread_id thread_get_main ();
58
57
bool thread_is_main ();
59
58
60
59
inline bool threads_same (thread_id a, thread_id b) {
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ namespace threading_impl {
29
29
using thread_id = ::DWORD;
30
30
31
31
inline thread_id thread_get_current () { return ::GetCurrentThreadId (); }
32
- thread_id thread_get_main ();
33
32
bool thread_is_main ();
34
33
inline bool threads_same (thread_id a, thread_id b) { return a == b; }
35
34
Original file line number Diff line number Diff line change @@ -55,11 +55,6 @@ class Thread {
55
55
return Thread (threading_impl::thread_get_current ());
56
56
}
57
57
58
- // / Returns the main thread in this program
59
- static Thread main () {
60
- return Thread (threading_impl::thread_get_main ());
61
- }
62
-
63
58
// / Returns true iff executed on the main thread
64
59
static bool onMainThread () {
65
60
return threading_impl::thread_is_main ();
Original file line number Diff line number Diff line change @@ -64,14 +64,9 @@ C11ThreadingHelper helper;
64
64
using namespace swift ;
65
65
using namespace threading_impl ;
66
66
67
- thread_id
68
- swift::threading_impl::thread_get_main () {
69
- return helper.main_thread ();
70
- }
71
-
72
67
bool
73
68
swift::threading_impl::thread_is_main () {
74
- return thrd_equal (thrd_current (), thread_get_main ());
69
+ return thrd_equal (thrd_current (), helper. main_thread ());
75
70
}
76
71
77
72
void
Original file line number Diff line number Diff line change
1
+ # If you update this, you also need to update the CMakeLists.txt file in
2
+ # stdlib/public/Threading
3
+
1
4
add_swift_host_library(swiftThreading STATIC
2
5
C11.cpp
3
- Darwin.cpp
4
6
Linux.cpp
5
- Nothreads.cpp
6
7
Pthreads.cpp
7
8
Win32 .cpp)
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -42,14 +42,9 @@ MainThreadRememberer rememberer;
42
42
using namespace swift ;
43
43
using namespace threading_impl ;
44
44
45
- thread_id
46
- swift::threading_impl::thread_get_main () {
47
- return rememberer.main_thread ();
48
- }
49
-
50
45
bool
51
46
swift::threading_impl::thread_is_main () {
52
- return pthread_equal (pthread_self (), thread_get_main ());
47
+ return pthread_equal (pthread_self (), rememberer. main_thread ());
53
48
}
54
49
55
50
void
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -44,14 +44,9 @@ pthread_cond_t onceCond = PTHREAD_COND_INITIALIZER;
44
44
using namespace swift ;
45
45
using namespace threading_impl ;
46
46
47
- thread_id
48
- swift::threading_impl::thread_get_main () {
49
- return rememberer.main_thread ();
50
- }
51
-
52
47
bool
53
48
swift::threading_impl::thread_is_main () {
54
- return pthread_equal (pthread_self (), thread_get_main ());
49
+ return pthread_equal (pthread_self (), rememberer. main_thread ());
55
50
}
56
51
57
52
void
Original file line number Diff line number Diff line change @@ -52,14 +52,9 @@ CONDITION_VARIABLE onceCond = CONDITION_VARIABLE_INIT;
52
52
using namespace swift ;
53
53
using namespace threading_impl ;
54
54
55
- thread_id
56
- swift::threading_impl::thread_get_main () {
57
- return rememberer.main_thread ();
58
- }
59
-
60
55
bool
61
56
swift::threading_impl::thread_is_main () {
62
- return ::GetCurrentThreadId () == thread_get_main ();
57
+ return ::GetCurrentThreadId () == rememberer. main_thread ();
63
58
}
64
59
65
60
void
Original file line number Diff line number Diff line change
1
+ # This is the counterpart to lib/Threading/CMakeLists.txt. Any updates
2
+ # need to be reflected in both places.
3
+
1
4
add_swift_target_library(swiftThreading OBJECT_LIBRARY
2
5
"${SWIFT_SOURCE_DIR} /lib/Threading/C11.cpp"
3
- "${SWIFT_SOURCE_DIR} /lib/Threading/Darwin.cpp"
4
6
"${SWIFT_SOURCE_DIR} /lib/Threading/Linux.cpp"
5
- "${SWIFT_SOURCE_DIR} /lib/Threading/Nothreads.cpp"
6
7
"${SWIFT_SOURCE_DIR} /lib/Threading/Pthreads.cpp"
7
8
"${SWIFT_SOURCE_DIR} /lib/Threading/Win32.cpp"
8
9
INSTALL_IN_COMPONENT never_install)
You can’t perform that action at this time.
0 commit comments