mutex Questions

3

Solved

Is there a C++ std::lock() like facility in Rust to prevent deadlocking in code like this: type Type0 = Arc<Mutex<u8>>; type Type1 = Arc<Mutex<u16>>; fn foo(a: Type0, b: T...
Progress asked 8/9, 2016 at 14:1

8

Solved

I have the following class. class Test{ public HashSet<string> Data = new HashSet<string>(); } I need to change the field "Data" from different threads, so I would like some opinion...
Untitled asked 20/9, 2013 at 17:57

8

Solved

I'm sure mutex isn't enough that's the reason the concept of condition variables exist; but it beats me and I'm not able to convince myself with a concrete scenario when a condition variable is ess...

8

Solved

There is a shared_mutex class planned for C++17. And shared_timed_mutex already in C++14. (Who knows why they came in that order, but whatever.) Then there is a recursive_mutex and a recursive_time...
Moneybags asked 14/4, 2016 at 10:0

10

Solved

I have found different articles about this exception but none of them was my case. Here is the source code: class Program { private static Mutex mutex; private static bool mutexIsLocked = false...
Bribery asked 26/1, 2012 at 11:31

4

Solved

When deploying Rails via Passenger or Mongrel you have multiple instances of the application running. What is the best practice or pattern to establish a mutex on shared resources such as a writing...
Phosphide asked 22/9, 2009 at 16:52

4

How to lock a function or the body of a function from being called by two threads in golang? My use case is that I have a webserver that is calling a serial interface which can only have one calle...
Sundsvall asked 10/9, 2017 at 7:39

9

Solved

After reading the Test-and-Set Wikipedia entry, I am still left with the question "What would a Test-and-Set be used for?" I realize that you can use it to implement Mutex (as described in wikiped...
Achromatin asked 23/9, 2008 at 13:22

3

Solved

There is a class template Foo<T>. And for some specific type, a function should use lock_guard. Here is the example code: #include <type_traits> #include <mutex> #include <vect...
Poohpooh asked 24/4, 2023 at 6:40

3

I have an application that use a lot of socketio request and I make bulk request. When receiving the data, I have to iterate through a list to add and remove item: List carlist; void receiveDat...
Hake asked 31/7, 2014 at 19:16

2

Solved

Consider the following function: std::shared_mutex mutex; void foo() { std::shared_lock readLock{ mutex }; // ... // read-only part of the function // ... { std::unique_lock lock{ mutex, ...
Whittaker asked 24/3, 2023 at 14:42

1

Solved

How can old school multi-threading (no wrapping mutex) can be achieve in Rust? And why is it undefined behavior? I have to build a highly concurrent physic simulation. I am supposed to do it in C, ...
Mapp asked 27/1, 2023 at 0:2

7

Solved

On Windows, it's common practice to create a named mutex and use the presence of that to determine that an instance of a given app is already running. This has its drawbacks, but mostly works. I c...
Colpitis asked 4/7, 2009 at 0:42

13

Solved

This is the code I implemented so far to create a single instance WPF application: #region Using Directives using System; using System.Globalization; using System.Reflection; using System.Th...
Obliteration asked 24/1, 2013 at 16:44

7

Solved

I'm working on an implementation of the "Fair Barbershop" problem in Ruby. This is for a class assignment, but I'm not looking for any handouts. I've been searching like crazy, but I cannot seem to...
Proteiform asked 29/3, 2011 at 20:54

2

Solved

I'm invoking an async implemented method: let mut safebrowsing: MutexGuard<Safebrowsing> = self.safebrowsing.lock().unwrap(); safebrowsing.is_safe(input: &message.content).await; The is_...
Biretta asked 29/8, 2021 at 21:10

7

Solved

If you have two threads within an application, and you don't want them to run a certain piece of code simultaneously, you can just put a lock around the piece of code, like this: lock (someObject)...
Arlinda asked 24/2, 2010 at 21:57

1

Solved

Suppose, countMe is a global variable and I am launching 10 threads at the same time to this while loop, is the variable countMe mutex protected in the predicate? I think because when the code reac...
Alasteir asked 21/11, 2022 at 2:24

5

Solved

Does a mutex lock access to variables globally, or just those in the same scope as the locked mutex? Note that I had to change the title of this question, as a lot of answers seem to be confused as...
Elurd asked 13/6, 2016 at 14:15

1

Solved

In his book, C++ Concurrency in Action, A. Williams introduces the concept of a lock hierarchy as a deadlock-avoidance mechanism. Below, I report a stripped down version of a HierarchicalMutex impl...
Nefen asked 23/10, 2022 at 14:28

7

Solved

I have 2 threads and a shared float global. One thread only writes to the variable while the other only reads from it, do I need to lock access to this variable? In other words: volatile float x; ...
Hogle asked 13/5, 2009 at 18:44

5

The pthread_mutex_timedlock documentation says that abs_timeout takes a CLOCK_REALTIME. However, we all know that it is inappropriate for timing a specific duration (due to system time adjustments)...
Laky asked 9/1, 2013 at 23:0

1

Background: CCL aka OpenMCL is a very nice, venerable, lightweight but fairly fast Common Lisp compiler. It's an excellent match for the RPi because it runs on 32-bit models, and isn't too memory i...
Discussion asked 18/9, 2022 at 20:26

1

Solved

What is an "async" mutex as opposed to a "normal" mutex? I believe this is the difference between tokio's Mutex and the normal std lib Mutex. But I don't get, conceptually, how ...
Tome asked 24/9, 2022 at 20:54

2

Solved

According to the Rust Embedded Book about concurrency, one of the better ways to share some data between contexts is using mutexes with refcells. I understand how they work and why this is necessar...
Denadenae asked 20/11, 2019 at 12:0

© 2022 - 2024 — McMap. All rights reserved.