-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
In mtx_lock(), I think you should trap the dead-lock with an assert:
if(res == EDEADLK) {
assert(false); // Dead-locks are undefined behaviour
return thrd_busy;
}
According to the C11 standard, a dead-lock is undefined behaviour. However, with POSIX threads, the behaviour is well defined. What we want to avoid is client code silently discarding dead-locks, by calling mtx_lock(), without paying attention to the return value, which turns into a no-op. Instead code should crash, at least in debug compiles, so programmers can see that they are relying on a deadlock (which is undefined).
What do you think ?
Metadata
Metadata
Assignees
Labels
No labels