Skip to content

Commit 897ab1a

Browse files
committed
remove libpwq
remove libpwq from gitsubmodules. remove support for building libpwq when building dispatch
1 parent 8b235c5 commit 897ab1a

File tree

9 files changed

+25
-33
lines changed

9 files changed

+25
-33
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "libpwq"]
2-
path = libpwq
3-
url = https://github.com/mheily/libpwq.git

Makefile.am

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44

55
ACLOCAL_AMFLAGS = -I m4
66

7-
if BUILD_OWN_PTHREAD_WORKQUEUES
8-
MAYBE_PTHREAD_WORKQUEUES = libpwq
9-
endif
10-
117
if BUILD_TESTS
128
MAYBE_TESTS = tests
139
endif
1410

1511
SUBDIRS= \
1612
dispatch \
17-
$(MAYBE_PTHREAD_WORKQUEUES) \
1813
man \
1914
os \
2015
private \

configure.ac

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ AS_IF([test -n "$apple_libpthread_source_path" -a -n "$apple_xnu_source_osfmk_pa
320320
AC_CHECK_HEADERS([pthread_machdep.h pthread/qos.h])
321321

322322
# pthread_workqueues.
323-
# Look for own version first, then for libpwq in our source tree, finally system version.
323+
# Look for own version first, than see if there is a system version.
324324
AC_ARG_ENABLE([internal-libpwq],
325325
[AS_HELP_STRING([--enable-internal-libpwq],
326326
[Use libdispatch's own implementation of pthread workqueues.])],,
@@ -336,26 +336,15 @@ AS_IF([test "x$enable_internal_libpwq" = "xyes"],
336336
[AC_DEFINE(DISPATCH_USE_INTERNAL_WORKQUEUE, 1, [Use libdispatch's own implementation of pthread_workqueue API])
337337
AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present])
338338
dispatch_use_internal_workqueue=true
339-
have_pthread_workqueues=true
340-
build_own_pthread_workqueues=false],
339+
have_pthread_workqueues=true],
341340
[dispatch_use_internal_workqueue=false
342-
AS_IF([test -f $srcdir/libpwq/configure.ac],
343-
[AC_DEFINE(BUILD_OWN_PTHREAD_WORKQUEUES, 1, [Define if building pthread work queues from source])
344-
ac_configure_args="--disable-libpwq-install $ac_configure_args"
345-
AC_CONFIG_SUBDIRS([libpwq])
346-
build_own_pthread_workqueues=true
347-
AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present])
341+
AC_CHECK_HEADERS([pthread/workqueue_private.h pthread_workqueue.h],
342+
[AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present])
348343
have_pthread_workqueues=true],
349-
[build_own_pthread_workqueues=false
350-
AC_CHECK_HEADERS([pthread/workqueue_private.h pthread_workqueue.h],
351-
[AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present])
352-
have_pthread_workqueues=true],
353-
[have_pthread_workqueues=false]
354-
)]
344+
[have_pthread_workqueues=false]
355345
)]
356346
)
357347
AM_CONDITIONAL(DISPATCH_USE_INTERNAL_WORKQUEUE, $dispatch_use_internal_workqueue)
358-
AM_CONDITIONAL(BUILD_OWN_PTHREAD_WORKQUEUES, $build_own_pthread_workqueues)
359348
AM_CONDITIONAL(HAVE_PTHREAD_WORKQUEUES, $have_pthread_workqueues)
360349

361350
AC_CHECK_HEADERS([libproc_internal.h], [], [], [#include <mach/mach.h>])

libpwq

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

src/Makefile.am

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,11 @@ if DISPATCH_USE_INTERNAL_WORKQUEUE
8888
PTHREAD_WORKQUEUE_LIBS=
8989
PTHREAD_WORKQUEUE_CFLAGS=
9090
else
91-
if BUILD_OWN_PTHREAD_WORKQUEUES
92-
PTHREAD_WORKQUEUE_LIBS=$(top_builddir)/libpwq/libpthread_workqueue.la
93-
PTHREAD_WORKQUEUE_CFLAGS=-I$(top_srcdir)/libpwq/include
94-
else
9591
if HAVE_PTHREAD_WORKQUEUES
9692
PTHREAD_WORKQUEUE_LIBS=-lpthread_workqueue
9793
PTHREAD_WORKQUEUE_CFLAGS=
9894
endif
9995
endif
100-
endif
10196

10297
if BUILD_OWN_BLOCKS_RUNTIME
10398
libdispatch_la_SOURCES+= BlocksRuntime/data.c BlocksRuntime/runtime.c

src/event/workqueue.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ _dispatch_workq_worker_register(dispatch_queue_t root_q, int priority)
8484
{
8585
dispatch_once_f(&_dispatch_workq_init_once_pred, NULL, &_dispatch_workq_init_once);
8686

87+
#if HAVE_DISPATCH_WORKQ_MONITORING
8788
dispatch_workq_monitor_t mon = &_dispatch_workq_monitors[priority];
8889
dispatch_assert(mon->dq == root_q);
8990
dispatch_tid tid = _dispatch_thread_getspecific(tid);
@@ -92,11 +93,13 @@ _dispatch_workq_worker_register(dispatch_queue_t root_q, int priority)
9293
int worker_id = mon->num_registered_tids++;
9394
mon->registered_tids[worker_id] = tid;
9495
_dispatch_unfair_lock_unlock(&mon->registered_tid_lock);
96+
#endif // HAVE_DISPATCH_WORKQ_MONITORING
9597
}
9698

9799
void
98100
_dispatch_workq_worker_unregister(dispatch_queue_t root_q, int priority)
99101
{
102+
#if HAVE_DISPATCH_WORKQ_MONITORING
100103
dispatch_workq_monitor_t mon = &_dispatch_workq_monitors[priority];
101104
dispatch_tid tid = _dispatch_thread_getspecific(tid);
102105
_dispatch_unfair_lock_lock(&mon->registered_tid_lock);
@@ -110,9 +113,12 @@ _dispatch_workq_worker_unregister(dispatch_queue_t root_q, int priority)
110113
}
111114
}
112115
_dispatch_unfair_lock_unlock(&mon->registered_tid_lock);
116+
#endif // HAVE_DISPATCH_WORKQ_MONITORING
113117
}
114118

115119

120+
#if HAVE_DISPATCH_WORKQ_MONITORING
121+
#if defined(__linux__)
116122
/*
117123
* For each pid that is a registered worker, read /proc/[pid]/stat
118124
* to get a count of the number of them that are actually runnable.
@@ -164,6 +170,9 @@ _dispatch_workq_count_runnable_workers(dispatch_workq_monitor_t mon)
164170

165171
_dispatch_unfair_lock_unlock(&mon->registered_tid_lock);
166172
}
173+
#else
174+
#error must define _dispatch_workq_count_runnable_workers
175+
#endif
167176

168177
static void
169178
_dispatch_workq_monitor_pools(void *context DISPATCH_UNUSED)
@@ -212,6 +221,8 @@ _dispatch_workq_monitor_pools(void *context DISPATCH_UNUSED)
212221
}
213222
}
214223
}
224+
#endif // HAVE_DISPATCH_WORKQ_MONITORING
225+
215226

216227
// temporary until we switch over to QoS based interface.
217228
static dispatch_queue_t
@@ -238,6 +249,7 @@ get_root_queue_from_legacy_priority(int priority)
238249
static void
239250
_dispatch_workq_init_once(void *context DISPATCH_UNUSED)
240251
{
252+
#if HAVE_DISPATCH_WORKQ_MONITORING
241253
int target_runnable = dispatch_hw_config(active_cpus);
242254
for (int i = 0; i < WORKQ_NUM_PRIORITIES; i++) {
243255
dispatch_workq_monitor_t mon = &_dispatch_workq_monitors[i];
@@ -255,6 +267,7 @@ _dispatch_workq_init_once(void *context DISPATCH_UNUSED)
255267
dispatch_source_set_event_handler_f(ds, _dispatch_workq_monitor_pools);
256268
dispatch_set_context(ds, ds); // avoid appearing as leaked
257269
dispatch_activate(ds);
270+
#endif // HAVE_DISPATCH_WORKQ_MONITORING
258271
}
259272

260273
#endif // DISPATCH_USE_INTERNAL_WORKQUEUE

src/event/workqueue_internal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,11 @@
4242
void _dispatch_workq_worker_register(dispatch_queue_t root_q, int priority);
4343
void _dispatch_workq_worker_unregister(dispatch_queue_t root_q, int priority);
4444

45+
#if defined(__linux__)
46+
#define HAVE_DISPATCH_WORKQ_MONITORING 1
47+
#else
48+
#define HAVE_DISPATCH_WORKQ_MONITORING 0
49+
#endif
50+
4551
#endif /* __DISPATCH_WORKQUEUE_INTERNAL__ */
4652

src/queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ _dispatch_root_queues_init_once(void *context DISPATCH_UNUSED)
727727
size_t i;
728728
for (i = 0; i < DISPATCH_ROOT_QUEUE_COUNT; i++) {
729729
bool overcommit = true;
730-
#if TARGET_OS_EMBEDDED || DISPATCH_USE_INTERNAL_WORKQUEUE
730+
#if TARGET_OS_EMBEDDED || (DISPATCH_USE_INTERNAL_WORKQUEUE && HAVE_DISPATCH_WORKQ_MONITORING)
731731
// some software hangs if the non-overcommitting queues do not
732732
// overcommit when threads block. Someday, this behavior should
733733
// apply to all platforms

tests/Makefile.am

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,11 @@ AM_OBJCFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CBLOCKS_FLAGS)
8888
AM_CXXFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CXXBLOCKS_FLAGS) $(BSD_OVERLAY_CFLAGS)
8989
AM_OBJCXXFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CXXBLOCKS_FLAGS)
9090

91-
if !BUILD_OWN_PTHREAD_WORKQUEUES
9291
if !DISPATCH_USE_INTERNAL_WORKQUEUE
9392
if HAVE_PTHREAD_WORKQUEUES
9493
PTHREAD_WORKQUEUE_LIBS=-lpthread_workqueue
9594
endif
9695
endif
97-
endif
9896

9997
if BUILD_OWN_BLOCKS_RUNTIME
10098
CBLOCKS_FLAGS+= -I$(top_srcdir)/src/BlocksRuntime

0 commit comments

Comments
 (0)