4 ms·
>it's worse in C pthread_mutex_lock(&mutex); setBit(&gpioCtx, bitPosition, 1); pthread_mutex_unlock(&mutex); It's not.
by foooorsyth 3y ago
>it's worse in C
pthread_mutex_lock(&mutex);
setBit(&gpioCtx, bitPosition, 1);
pthread_mutex_unlock(&mutex);
It's not.
- baq 3y agoAgree to disagree.
- gaganyaan 3y agoThat's a terrible API. If you forget to unlock it, have fun pulling your hair out while debugging. Rust makes it so that you can't forget.
- foooorsyth 3y agolol POSIX threads are far more battle-proven than any threading API in Rust. All of the underlying multi-threading on the system you made your comment from is using pthreads. It works fine in reality, despite all the pearl clutching. >Rust makes it so that you can't forget. And the tradeoff is an unreadable, puke-inducing one-liner. You can do a (readable) scoped lock with a macro in C (GCC defines the __attribute__ cleanup) or RAII-style with destructors in C++.
- gaganyaan 3y ago"Works fine" is an interesting choice of words for the absolute tire fire of a tech stack that modern tech currently depends on. You should probably see a doctor about your hyperemesis.