summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2012-05-10 09:30:37 +0000
committerdavidxu <davidxu@FreeBSD.org>2012-05-10 09:30:37 +0000
commit0b215c6420b1aa0abefea0c0d0a5fe84259fa572 (patch)
treefb93cf1565aab8fa3b9b6222414b53b9f0a3e5e1 /lib/libthr
parent041725774601ccd72b5c1379a8450c6b76793138 (diff)
downloadFreeBSD-src-0b215c6420b1aa0abefea0c0d0a5fe84259fa572.zip
FreeBSD-src-0b215c6420b1aa0abefea0c0d0a5fe84259fa572.tar.gz
Create a common function lookup() to search a chan, this eliminates
redundant SC_LOOKUP() calling.
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_sleepq.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/libthr/thread/thr_sleepq.c b/lib/libthr/thread/thr_sleepq.c
index 98cb5a1..c5dcac5 100644
--- a/lib/libthr/thread/thr_sleepq.c
+++ b/lib/libthr/thread/thr_sleepq.c
@@ -94,19 +94,23 @@ _sleepq_unlock(void *wchan)
THR_LOCK_RELEASE(curthread, &sc->sc_lock);
}
-struct sleepqueue *
-_sleepq_lookup(void *wchan)
+static inline struct sleepqueue *
+lookup(struct sleepqueue_chain *sc, void *wchan)
{
- struct sleepqueue_chain *sc;
struct sleepqueue *sq;
- sc = SC_LOOKUP(wchan);
LIST_FOREACH(sq, &sc->sc_queues, sq_hash)
if (sq->sq_wchan == wchan)
return (sq);
return (NULL);
}
+struct sleepqueue *
+_sleepq_lookup(void *wchan)
+{
+ return (lookup(SC_LOOKUP(wchan), wchan));
+}
+
void
_sleepq_add(void *wchan, struct pthread *td)
{
@@ -114,7 +118,7 @@ _sleepq_add(void *wchan, struct pthread *td)
struct sleepqueue *sq;
sc = SC_LOOKUP(wchan);
- sq = _sleepq_lookup(wchan);
+ sq = lookup(sc, wchan);
if (sq != NULL) {
SLIST_INSERT_HEAD(&sq->sq_freeq, td->sleepqueue, sq_flink);
} else {
OpenPOWER on IntegriCloud