[beast: 3/57] SFI: use std::condition_variable and std::mutex instead of homegrown primitives
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 3/57] SFI: use std::condition_variable and std::mutex instead of homegrown primitives
- Date: Sun, 23 Jul 2017 09:58:02 +0000 (UTC)
commit 53da6a0589352b364bfb253cc61cee6d62ec619c
Author: Tim Janik <timj gnu org>
Date: Tue Jul 4 13:07:55 2017 +0200
SFI: use std::condition_variable and std::mutex instead of homegrown primitives
Signed-off-by: Tim Janik <timj gnu org>
sfi/sficomport.cc | 7 +++----
sfi/sficomport.hh | 5 +++--
sfi/sfimemory.cc | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/sfi/sficomport.cc b/sfi/sficomport.cc
index dd1c0bb..d63f10b 100644
--- a/sfi/sficomport.cc
+++ b/sfi/sficomport.cc
@@ -365,7 +365,7 @@ sfi_com_port_send_bulk (SfiComPort *port,
else
link->p2queue = sfi_ring_concat (link->p2queue, target);
if (link->waiting)
- link->wcond.signal();
+ link->wcond.notify_one();
else
wakeup = first ? link->wakeup2 : link->wakeup1;
link->mutex.unlock();
@@ -541,7 +541,7 @@ sfi_com_port_recv_intern (SfiComPort *port,
if (!port->rvalues && port->link)
{
SfiComPortLink *link = port->link;
- link->mutex.lock();
+ std::unique_lock<std::mutex> link_lock (link->mutex);
refetch:
if (port == link->port1)
port->rvalues = link->p2queue, link->p2queue = NULL;
@@ -550,11 +550,10 @@ sfi_com_port_recv_intern (SfiComPort *port,
if (!port->rvalues && blocking)
{
link->waiting = TRUE;
- link->wcond.wait (link->mutex);
+ link->wcond.wait (link_lock);
link->waiting = FALSE;
goto refetch;
}
- link->mutex.unlock();
}
else if (!port->rvalues)
{
diff --git a/sfi/sficomport.hh b/sfi/sficomport.hh
index ffb07cc..1f71edc 100644
--- a/sfi/sficomport.hh
+++ b/sfi/sficomport.hh
@@ -4,6 +4,7 @@
#include <sfi/sfitypes.hh>
#include <sfi/sfiring.hh>
+#include <condition_variable>
#define SFI_COM_PORT_MAGIC (0x42534500 /* "BSE\0" */)
@@ -46,7 +47,7 @@ struct SfiComPort {
struct SfiComPortLink
{
- Bse::Mutex mutex;
+ std::mutex mutex;
guint ref_count;
SfiComPort *port1;
std::function<void()> wakeup1;
@@ -54,7 +55,7 @@ struct SfiComPortLink
std::function<void()> wakeup2;
SfiRing *p1queue;
SfiRing *p2queue;
- Bse::Cond wcond;
+ std::condition_variable wcond;
bool waiting;
};
diff --git a/sfi/sfimemory.cc b/sfi/sfimemory.cc
index e0542bb..d33ab92 100644
--- a/sfi/sfimemory.cc
+++ b/sfi/sfimemory.cc
@@ -6,7 +6,7 @@
#define TS8_SIZE (MAX (sizeof (GTrashStack), 8))
#define DBG8_SIZE (MAX (sizeof (gsize), 8))
/* --- variables --- */
-static Rapicorn::Mutex global_memory_mutex;
+static std::mutex global_memory_mutex;
static GTrashStack *simple_cache[SIMPLE_CACHE_SIZE] = { 0, 0, 0, /* ... */ };
static gulong memory_allocated = 0;
/* --- functions --- */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]