emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-bug-tracker] bug#6729: closed ([PATCH] sort: omit unnecessary mut


From: GNU bug Tracking System
Subject: [Emacs-bug-tracker] bug#6729: closed ([PATCH] sort: omit unnecessary mutex unlock+lock; simplify heap access)
Date: Mon, 26 Jul 2010 09:55:01 +0000

Your message dated Mon, 26 Jul 2010 10:53:25 +0100
with message-id <address@hidden>
and subject line Re: bug#6729: [PATCH] sort: omit unnecessary mutex 
unlock+lock; simplify heap access
has caused the GNU bug report #6729,
regarding [PATCH] sort: omit unnecessary mutex unlock+lock; simplify heap access
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
6729: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6729
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH] sort: omit unnecessary mutex unlock+lock; simplify heap access Date: Sun, 25 Jul 2010 20:57:24 -0700 User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100527 Thunderbird/3.0.5
This removes an unnecessary mutex lock+unlock
and prepares for a refactoring patch to heap.c that I'll
install shortly.

>From 7cc2429f13db9b0b70572ac1879506f4e444f4c6 Mon Sep 17 00:00:00 2001
From: Paul R. Eggert <address@hidden>
Date: Sun, 25 Jul 2010 20:54:55 -0700
Subject: [PATCH] sort: omit unnecessary mutex unlock+lock; simplify heap access

* src/sort.c (queue_pop): Omit unnecessary unlock+lock after
pthread_cond_wait returns.  Don't access "count" member of the
heap; any efficiency gains should be quite minor, the access
complicates this code, and "count" should be private anyway.
---
 src/sort.c |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/src/sort.c b/src/sort.c
index ea2720f..577521d 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -3173,20 +3173,11 @@ queue_insert (struct merge_node_queue *queue, struct 
merge_node *node)
 static inline struct merge_node *
 queue_pop (struct merge_node_queue *queue)
 {
-  struct merge_node *node = NULL;
-
-  while (!node)
-    {
-      pthread_mutex_lock (&queue->mutex);
-      if (queue->priority_queue->count)
-        node = heap_remove_top (queue->priority_queue);
-      else
-        {
-          /* Go into conditional wait if no NODE is immediately available.  */
-          pthread_cond_wait (&queue->cond, &queue->mutex);
-        }
-      pthread_mutex_unlock (&queue->mutex);
-    }
+  struct merge_node *node;
+  pthread_mutex_lock (&queue->mutex);
+  while (! (node = heap_remove_top (queue->priority_queue)))
+    pthread_cond_wait (&queue->cond, &queue->mutex);
+  pthread_mutex_unlock (&queue->mutex);
   lock_node (node);
   node->queued = false;
   return node;
-- 
1.7.1




--- End Message ---
--- Begin Message --- Subject: Re: bug#6729: [PATCH] sort: omit unnecessary mutex unlock+lock; simplify heap access Date: Mon, 26 Jul 2010 10:53:25 +0100 User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3
On 26/07/10 04:57, Paul Eggert wrote:
> This removes an unnecessary mutex lock+unlock
> and prepares for a refactoring patch to heap.c that I'll
> install shortly.

closing...

thanks,
Pádraig.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]