Timeline for Specify that a method needs a mutex held when calling
Current License: CC BY-SA 4.0
11 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 6, 2021 at 12:44 | answer | added | Homer512 | timeline score: 2 | |
| Nov 30, 2021 at 8:30 | comment | added | gnasher729 | Daniel, lazy is good for software developers. | |
| Nov 29, 2021 at 21:06 | comment | added | gnasher729 | You should always, always hold a mutex for the minimum time possible. Look for recursive mutexes, and lock if you have a try lock functionality in your programming environment. Checking whether a mutex is locked and then locking it is unsafe. | |
| Nov 29, 2021 at 18:00 | history | tweeted | twitter.com/StackSoftEng/status/1465380036245082113 | ||
| Nov 29, 2021 at 16:23 | comment | added | Vincent Savard | Concurrency is indeed hard, but the usage of reentrant locks is quite widespread when the use case warrants it. I think what could also be helpful to answer your question is to have a more practical example of why you need the caller to hold the lock, and how the lookupData method is intended to be used (Can it be called from other classes?). | |
| Nov 29, 2021 at 15:24 | history | edited | Daniel McLaury | CC BY-SA 4.0 | deleted 52 characters in body |
| Nov 29, 2021 at 15:24 | comment | added | Daniel McLaury | I haven't heard of recursive_mutex before. It's an interesting idea but (without any experience with them) sounds like it could easily open up a whole can of worms by letting people handle mutexes fairly lazily. | |
| Nov 29, 2021 at 15:07 | comment | added | Bart van Ingen Schenau | Have you considered recursive mutexes? Those can be locked multiple times by one thread. | |
| Nov 29, 2021 at 15:07 | comment | added | Vincent Savard | Could you make your lock reentrant, and lock from the caller of the function and from the function as well? | |
| Nov 29, 2021 at 14:53 | history | edited | Daniel McLaury | CC BY-SA 4.0 | added 145 characters in body |
| Nov 29, 2021 at 14:48 | history | asked | Daniel McLaury | CC BY-SA 4.0 |