Skip to content
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

Add ReusableBlockingVariable to allow reset the state of the variable… #721

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

guenhter
Copy link

@guenhter guenhter commented Apr 18, 2017

Often it's needed to use the same BlockingVariable again but reset it. E.g. when the variable is used for Messaging and is contained in a consumer. Than it isn't always that easy to replace the existing variable with a new instance. So I added a simple reset method which resets the value and the CountDownLatch of the BlockingVariable.

This also was suggested in
#312

So it is now possible to do:

BlockingVariable<String> b = ...
// do something async with the var

when:
sender.send("val1")
then:
b.get() == "val1"

when:
b.reset()
sender.send("val2")
then:
b.get() == "val2"

when:
b.reset()
sender.error();
b.get()
then:
thrown(SpockTimeoutError)

(I know, this samples can be split up to own tests, but there are other circumstances where such cases are needed)


This change is Reviewable

@codecov
Copy link

codecov bot commented Apr 18, 2017

Codecov Report

Merging #721 into master will increase coverage by 0.02%.
The diff coverage is 92.85%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #721      +/-   ##
============================================
+ Coverage     73.16%   73.18%   +0.02%     
- Complexity     3088     3094       +6     
============================================
  Files           341      342       +1     
  Lines          9639     9653      +14     
  Branches       1201     1201              
============================================
+ Hits           7052     7065      +13     
- Misses         2144     2145       +1     
  Partials        443      443
Impacted Files Coverage Δ Complexity Δ
...ock/util/concurrent/ReuseableBlockingVariable.java 92.85% <92.85%> (ø) 6 <6> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e9d7edc...d52ea1b. Read the comment docs.

@leonard84
Copy link
Member

FYI, we won't merge any new features until 1.1 is released.

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

Successfully merging this pull request may close these issues.

2 participants