Rust: Tracking issue for sync::Semaphore

Created on 13 Aug 2015  路  8Comments  路  Source: rust-lang/rust

This is a tracking issue for the unstable semaphore feature of the standard library.

  • Should we have this kind of semaphore?
  • Should we allow negative counts?
  • Should there be an RAII guard for a "resource"?

Decision!

B-unstable T-libs final-comment-period

Most helpful comment

How about re-adding Semaphores? It's a very useful synchronization method and sometimes works better than Mutexes + CondVar. I've seen many crates implementing Semaphores, people are interested. It would be great if they were supported in std.

All 8 comments

:bell: This issue is now entering its final comment period for deprecation :bell:

If this is used widely, however, we can reconsider!

The long-term vision of concurrency support within std is a bit unclear. The deprecation here reflects a general desire to stick to binding system primitives (as we do with locks). For now, user-space synchronization can live out of tree. (Under this rubric, channels don't really belong either, and in hindsight that would probably have been a reasonable call.)

All that said, in the long run I believe that it's important for Rust to have some official user-space concurrency constructs. This could be a rust-lang crate, or eventually land in std.

Was looking for names Semaphore for Intra-Process synchronization like in your repo:
http://alexcrichton.com/ipc-rs/ipc/struct.Semaphore.html
This seems to be just a counter protected by a Mutex?

@fritzsche a semaphore is a standard synchronization primitive: https://en.wikipedia.org/wiki/Semaphore_(programming)

@fritzsche yeah that repo is for OS semaphores which are normally some form of IPC as well, but as @sfackler mentioned a semaphore is also a synchronization primitive.

This is also partly why I'd like to deprecate for now to avoid confusion about what it is.

The libs team discussed this in triage yesterday and the decision was to deprecate

How about re-adding Semaphores? It's a very useful synchronization method and sometimes works better than Mutexes + CondVar. I've seen many crates implementing Semaphores, people are interested. It would be great if they were supported in std.

In C++ semaphores are missing, so we resorted to POSIX semaphores. It would be nice if Rust supported them out of the box

Was this page helpful?
0 / 5 - 0 ratings