Skip to content

Commit

Permalink
Change Waiter::wait to consume self
Browse files Browse the repository at this point in the history
This fixes a bug where the compiler complained about lacking `mut`
annotations when `groth16` was enabled but `multicore` was disabled.
The type of `Waiter::wait` changed based on whether or not `multicore`
was enabled; feature flags should only add APIs, not change them.
  • Loading branch information
str4d committed Sep 9, 2021
1 parent 2e70d70 commit cb684da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ and this project adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Compiling with `--no-default-features --features groth16` (i.e. disabling the
`multicore` feature flag) works again.

### Changed
- `bellman::multicore::Waiter::wait` now consumes `self` (better reflecting the
fact that you can't wait on the same result twice), instead of taking `&self`
with `multicore` enabled and `&mut self` with multicore disabled.

## [0.11.0] - 2021-09-08
### Added
Expand Down
8 changes: 4 additions & 4 deletions src/multicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ mod implementation {
}

impl<T> Waiter<T> {
/// Wait for the result.
pub fn wait(&self) -> T {
/// Consumes this waiter and blocks until the result is ready.
pub fn wait(self) -> T {
// This will be Some if this thread is in the global thread pool.
if rayon::current_thread_index().is_some() {
let msg = "wait() cannot be called from within a thread pool since that would lead to deadlocks";
Expand Down Expand Up @@ -177,8 +177,8 @@ mod implementation {
}

impl<T> Waiter<T> {
/// Wait for the result.
pub fn wait(&mut self) -> T {
/// Consumes this waiter and blocks until the result is ready.
pub fn wait(mut self) -> T {
self.val.take().expect("unmet data dependency")
}

Expand Down

0 comments on commit cb684da

Please sign in to comment.