sunfishcode/mustang

Support `std::sync::Condvar`

sunfishcode opened this issue · 4 comments

Unless there are any complications, this should just be a matter of implementing pthread_cond_* in terms of origin::Condvar.

I'd love to work on this, though can't say for sure that I'll find the necessary time. Looking at the unimplemented pthread_* stubs in c-scape/src/lib.rs, I'm immediately surprised thta so many of these functions don't have any arguments, e.g. all of pthread_cond_init / pthread_cond_signal / pthread_cond_destroy. We'll see where this goes... 🙂

Sounds great! Feel free to ask questions. The missing arguments thing is just laziness :-}. extern "C" functions kind of work if you pass them more arguments they expect, and it's a little easier to define stubs that way. To implement actually implement them, we'll need to use the proper signatures.

Take a look at PthreadMutexT and PthreadMutexattrT for examples of how to implement PthreadCondT (aka pthread_cond_t) and PthreadCondattrT (aka pthread_condattr_t).

I don't think I'll have much time to work on this over the next week, if sbd. else is interested in picking the work up where I left it (all I did so far is figuring out how to define the two libc types and updating the related function signatures), feel free to.

As an update here, mustang is no longer using parking_lot, so now this should use origin::CondVar instead.