This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
many-reader mutexes: Change structure element name
authorKarl Williamson <khw@cpan.org>
Thu, 10 Dec 2020 17:11:34 +0000 (10:11 -0700)
committerKarl Williamson <khw@cpan.org>
Sat, 12 Dec 2020 15:58:30 +0000 (08:58 -0700)
The old name did not encompass all the possible reasons for the
mutex signal condition to be invoked

perl.h
thread.h

diff --git a/perl.h b/perl.h
index a839ef9..d5cbf48 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -3344,7 +3344,7 @@ typedef pthread_key_t     perl_key;
 /* Many readers; single writer */
 typedef struct {
     perl_mutex lock;
 /* Many readers; single writer */
 typedef struct {
     perl_mutex lock;
-    perl_cond  zero_readers;
+    perl_cond  wakeup;
     Size_t     readers_count;
 } perl_RnW1_mutex_t;
 
     Size_t     readers_count;
 } perl_RnW1_mutex_t;
 
index b34af65..14fc1c5 100644 (file)
--- a/thread.h
+++ b/thread.h
         MUTEX_LOCK(mutex.lock);                                     \
         (mutex)->readers_count--;                                   \
         if ((mutex)->readers_count <= 0) {                          \
         MUTEX_LOCK(mutex.lock);                                     \
         (mutex)->readers_count--;                                   \
         if ((mutex)->readers_count <= 0) {                          \
-            COND_SIGNAL(mutex.zero_readers);                        \
+            COND_SIGNAL(mutex.wakeup);                              \
             (mutex)->readers_count = 0;                             \
         }                                                           \
         MUTEX_UNLOCK(mutex.lock);                                   \
             (mutex)->readers_count = 0;                             \
         }                                                           \
         MUTEX_UNLOCK(mutex.lock);                                   \
         do {                                                        \
             if ((mutex)->readers_count == 0)                        \
                 break;                                              \
         do {                                                        \
             if ((mutex)->readers_count == 0)                        \
                 break;                                              \
-            COND_WAIT(mutex.zero_readers, mutex.lock);              \
+            COND_WAIT(mutex.wakeup, mutex.lock);                    \
         }                                                           \
         while (1);                                                  \
                                                                     \
         }                                                           \
         while (1);                                                  \
                                                                     \
 
 #  define PERL_WRITE_UNLOCK(mutex)                                  \
     STMT_START {                                                    \
 
 #  define PERL_WRITE_UNLOCK(mutex)                                  \
     STMT_START {                                                    \
-        COND_SIGNAL(mutex.readers_now_zero);                        \
+        COND_SIGNAL(mutex.wakeup);                                  \
         MUTEX_UNLOCK(mutex.lock);                                   \
     } STMT_END
 
 #  define PERL_RW_MUTEX_INIT(mutex)                                 \
     STMT_START {                                                    \
         MUTEX_INIT(mutex.lock);                                     \
         MUTEX_UNLOCK(mutex.lock);                                   \
     } STMT_END
 
 #  define PERL_RW_MUTEX_INIT(mutex)                                 \
     STMT_START {                                                    \
         MUTEX_INIT(mutex.lock);                                     \
-        COND_INIT(mutex.zero_readers);                              \
+        COND_INIT(mutex.wakeup);                                    \
         (mutex)->readers_count = 0;                                 \
     } STMT_END
 
 #  define PERL_RW_MUTEX_DESTROY(mutex)                              \
     STMT_START {                                                    \
         (mutex)->readers_count = 0;                                 \
     } STMT_END
 
 #  define PERL_RW_MUTEX_DESTROY(mutex)                              \
     STMT_START {                                                    \
-        COND_DESTROY(mutex.zero_readers);                           \
+        COND_DESTROY(mutex.wakeup);                                 \
         MUTEX_DESTROY(mutex.lock);                                  \
     } STMT_END
 
         MUTEX_DESTROY(mutex.lock);                                  \
     } STMT_END