[beast: 58/95] BSE: use recursive Rapicorn Mutex for engine nodes



commit 27119f1f3a686a376311c0899077eab33728608a
Author: Tim Janik <timj gnu org>
Date:   Wed Mar 20 03:38:06 2013 +0100

    BSE: use recursive Rapicorn Mutex for engine nodes

 bse/bseengine.cc      |    2 +-
 bse/bseenginenode.hh  |    6 +++---
 bse/bseengineutils.cc |    2 +-
 sfi/sfiwrapper.hh     |    1 +
 4 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/bse/bseengine.cc b/bse/bseengine.cc
index c2bad61..0806cd7 100644
--- a/bse/bseengine.cc
+++ b/bse/bseengine.cc
@@ -62,7 +62,7 @@ bse_module_new (const BseModuleClass *klass,
   node->outputs = ENGINE_NODE_N_OSTREAMS (node) ? sfi_new_struct0 (EngineOutput, ENGINE_NODE_N_OSTREAMS 
(node)) : NULL;
   node->output_nodes = NULL;
   node->integrated = FALSE;
-  sfi_rec_mutex_init (&node->rec_mutex);
+  new (&node->rec_mutex) Bse::Mutex (Bse::RECURSIVE_LOCK);
   for (i = 0; i < ENGINE_NODE_N_OSTREAMS (node); i++)
     node->outputs[i].buffer = node->module.ostreams[i].values;
   node->flow_jobs = NULL;
diff --git a/bse/bseenginenode.hh b/bse/bseenginenode.hh
index 0931018..c537520 100644
--- a/bse/bseenginenode.hh
+++ b/bse/bseenginenode.hh
@@ -17,8 +17,8 @@ G_BEGIN_DECLS
 #define        ENGINE_NODE_IS_SCHEDULED(node)  (ENGINE_NODE (node)->sched_tag)
 #define        ENGINE_NODE_IS_CHEAP(node)      (((node)->module.klass->mflags & BSE_COST_CHEAP) != 0)
 #define        ENGINE_NODE_IS_EXPENSIVE(node)  (((node)->module.klass->mflags & BSE_COST_EXPENSIVE) != 0)
-#define        ENGINE_NODE_LOCK(node)          sfi_rec_mutex_lock (&(node)->rec_mutex)
-#define        ENGINE_NODE_UNLOCK(node)        sfi_rec_mutex_unlock (&(node)->rec_mutex)
+#define        ENGINE_NODE_LOCK(node)          (node)->rec_mutex.lock()
+#define        ENGINE_NODE_UNLOCK(node)        (node)->rec_mutex.unlock()
 #define        ENGINE_MODULE_IS_VIRTUAL(mod)   (ENGINE_NODE_IS_VIRTUAL (ENGINE_NODE (mod)))
 /* --- typedefs --- */
 typedef struct _EngineNode     EngineNode;
@@ -158,7 +158,7 @@ typedef struct
 struct _EngineNode             /* fields sorted by order of processing access */
 {
   BseModule     module;
-  BirnetRecMutex        rec_mutex;     /* processing lock */
+  Bse::Mutex    rec_mutex;     /* processing lock */
   guint64       counter;       /* <= Bse::TickStamp::current() */
   EngineInput  *inputs;        /* [ENGINE_NODE_N_ISTREAMS()] */
   EngineJInput **jinputs;      /* [ENGINE_NODE_N_JSTREAMS()][jstream->jcount] */
diff --git a/bse/bseengineutils.cc b/bse/bseengineutils.cc
index ee63d95..b4eee78 100644
--- a/bse/bseengineutils.cc
+++ b/bse/bseengineutils.cc
@@ -81,7 +81,6 @@ bse_engine_free_node (EngineNode *node)
   g_return_if_fail (node->boundary_jobs == NULL);
   g_return_if_fail (node->tjob_head == NULL);
   g_return_if_fail (node->probe_jobs == NULL);
-  sfi_rec_mutex_destroy (&node->rec_mutex);
   if (node->module.ostreams)
     {
       /* bse_engine_block_size() may have changed since allocation */
@@ -105,6 +104,7 @@ bse_engine_free_node (EngineNode *node)
     }
   klass = node->module.klass;
   user_data = node->module.user_data;
+  node->rec_mutex.~Mutex();
   sfi_delete_struct (EngineNode, node);
   /* allow the free function to free the klass as well */
   if (klass->free)
diff --git a/sfi/sfiwrapper.hh b/sfi/sfiwrapper.hh
index 315fd62..baa7d9b 100644
--- a/sfi/sfiwrapper.hh
+++ b/sfi/sfiwrapper.hh
@@ -13,6 +13,7 @@ using Rapicorn::ThreadInfo;
 using Rapicorn::EventFd;
 using Rapicorn::Spinlock;
 using Rapicorn::Mutex;
+using Rapicorn::RECURSIVE_LOCK;
 using Rapicorn::Cond;
 using Rapicorn::AsyncBlockingQueue;
 


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