Skip to content

sync::mutex::StaticMutex disappeared from public API, perhaps unintentionally? #19379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
emk opened this issue Nov 28, 2014 · 3 comments
Closed

Comments

@emk
Copy link
Contributor

emk commented Nov 28, 2014

This seems to have been removed here, as part of the sync cleanup for #19274: 689ef2d

The commit message says:

Because this removes the libsync crate, it is a:

[breaking-change]

However, all uses of libsync should be able to reroute through
std::sync and std::comm instead.

My use-case for StaticMutex was protecting global state in C libraries in emk/rust-cld2 using code like:

extern crate sync;
use sync::mutex::{StaticMutex, MUTEX_INIT};

static LIBRARY_LOCK: StaticMutex = MUTEX_INIT;

fn access_global_resource() {
    let _ = LIBRARY_LOCK.lock();
    unsafe { call_thread_unsafe_c_api(); }
}

Is there a clean way to do this with guards, etc.? I suppose I could use Once to bootstrap my way up to a global mutex, and use that to guard call_thread_unsafe_c_api, but that seems a lot more complicated than using StaticMutex. Am I simply missing the obvious solution here?

Thank you very much for working to rationalize sync!

cc @bors @alexcrichton

emk added a commit to emk/rust-cld2 that referenced this issue Nov 28, 2014
It looks like this library feature is trying to disappear out from under
us:

rust-lang/rust#19379

This will patch things up for now.
@sfackler
Copy link
Member

It lives in librustrt right now, though I believe that crate will be subsumed into libstd as well soon: http://doc.rust-lang.org/rustrt/mutex/

@emk
Copy link
Contributor Author

emk commented Nov 28, 2014

Thank you! I've switched from StaticMutex to StaticNativeMutex, because
StaticMutex seems to have gone missing.

It's nice to have a static mutex type of some sort for protecting external
C APIs.
Le Fri Nov 28 2014 at 11:53:05, Steven Fackler [email protected] a
écrit :

It lives in librustrt right now, though I believe that crate will be
subsumed into libstd as well soon: http://doc.rust-lang.org/rustrt/mutex/


Reply to this email directly or view it on GitHub
#19379 (comment).

@kmcallister
Copy link
Contributor

StaticMutex is back in std::sync. I believe there's no StaticNativeMutex anymore, because that's the only kind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants