Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for static synchronization primitives #27717
Comments
alexcrichton
added
T-libs
B-unstable
labels
Aug 12, 2015
This comment has been minimized.
This comment has been minimized.
|
cc @eddyb |
This comment has been minimized.
This comment has been minimized.
|
Alternatively we could put some code into |
This comment has been minimized.
This comment has been minimized.
|
The I wrote down an idea for such a system a few months ago, in an internals.rust-lang.org post, might still be relevant. |
This comment has been minimized.
This comment has been minimized.
|
Definitely with @eddyb for the long term, but in the short term would be nice if |
homu
added a commit
to autumnai/collenchyma
that referenced
this issue
Dec 2, 2015
alexcrichton
added
the
I-nominated
label
Apr 19, 2016
This comment has been minimized.
This comment has been minimized.
|
The libs team is thinking of deprecating these APIs in favor of the |
alexcrichton
added
final-comment-period
and removed
I-nominated
labels
Apr 29, 2016
This comment has been minimized.
This comment has been minimized.
|
The parking_lot crate has implementations of |
This comment has been minimized.
This comment has been minimized.
|
@Amanieu I prefer that to any sort of scheme which magically makes |
This comment has been minimized.
This comment has been minimized.
|
The libs team discussed this during triage yesterday and the decision was to deprecate. This seems easily-replaceable enough with the |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 17, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 17, 2016
alexcrichton
referenced this issue
May 17, 2016
Merged
std: Stabilize APIs for the 1.10 release #33699
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 18, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 18, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 18, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 23, 2016
bors
added a commit
that referenced
this issue
May 23, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 23, 2016
bors
added a commit
that referenced
this issue
May 23, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 23, 2016
bors
added a commit
that referenced
this issue
May 24, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 24, 2016
bors
added a commit
that referenced
this issue
May 24, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 24, 2016
bors
added a commit
that referenced
this issue
May 25, 2016
bors
added a commit
that referenced
this issue
May 25, 2016
bors
added a commit
that referenced
this issue
May 26, 2016
bors
closed this
in
#33699
May 26, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
May 26, 2016
This comment has been minimized.
This comment has been minimized.
|
Migration path from static LOCK: StaticMutex = MUTEX_INIT;Replace it with: lazy_static! {
pub static ref LOCK: Mutex<()> = Mutex::new(());
}If you’re protecting data with the mutex, then you can use something better than |
This comment has been minimized.
This comment has been minimized.
Doesn’t this have more runtime cost? It has two synchronization points ( |
This comment has been minimized.
This comment has been minimized.
|
The |
srinivasreddy
added a commit
to srinivasreddy/rust
that referenced
this issue
May 28, 2016
srinivasreddy
added a commit
to srinivasreddy/rust
that referenced
this issue
May 29, 2016
This comment has been minimized.
This comment has been minimized.
|
The |
alexcrichton commentedAug 12, 2015
This is a tracking issue for the unstable
static_mutex,static_condvar, andstatic_rwlockfeatures in the standard library. Each of these represents a separateStaticFootype (next to the typeFoo) to provide a synchronization primitive that can be constructed in a static context. This unfortunately has a few drawbacks:StaticMutexdoes not have a type parameter for the data that it protects (unlikeMutex<T>)Ideally all of these types would be removed in favor of being able to construct a
Mutex<T>statically. This can almost be done withconst fn, but the implementation of each of these primitives currently has an internalBoxwhich can't be constructed in a static context. A solution should probably be devised along the lines of:Boxat runtime and just a plain address when inlined into a static. It also wouldn't have a destructor for the purposes of checking whether statics have destructors.boxoperator could be allowed in aconst fncontext perhaps. Instead of allocating memory on the heap it could instead "allocate" memory in the data section of an executable at compile time. The destructor would end up being ignored and never run somehow, possibly.