-
Notifications
You must be signed in to change notification settings - Fork 14
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
waiting on register modification events #156
Draft
Krastanov
wants to merge
9
commits into
QuantumSavory:master
Choose a base branch
from
hanakl:bounty_waiters
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
067051d
Add tag_waiter
hanakl b48b23e
Add a waiter for stateindices
hanakl c11673f
Fixes on including AsymmetricSemaphore and StateIndexVector base methods
hanakl 6388b6f
Remove StateIndexVector
hanakl 66024d3
Add tests for AsymmetricSemaphore
hanakl 9e628a5
Add tests for entanglement_consumer
hanakl 06b1f0c
Fix a typo in protocolzoo
hanakl 708a12c
Fix a typo
hanakl 68af5bd
Implement waiting logic to swapping and cutoff protocols
hanakl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using ConcurrentSim | ||
using ResumableFunctions | ||
import Base: unlock, lock | ||
|
||
"""Multiple processes can wait on this semaphore for a permission to run given by another process""" | ||
struct AsymmetricSemaphore | ||
nbwaiters::Ref{Int} | ||
lock::Resource | ||
end | ||
AsymmetricSemaphore(sim) = AsymmetricSemaphore(Ref(0), Resource(sim,1,level=1)) # start locked | ||
|
||
function Base.lock(s::AsymmetricSemaphore) | ||
return @process _lock(s.lock.env, s) | ||
end | ||
|
||
@resumable function _lock(sim, s::AsymmetricSemaphore) | ||
s.nbwaiters[] += 1 | ||
@yield lock(s.lock) | ||
s.nbwaiters[] -= 1 | ||
if s.nbwaiters[] > 0 | ||
unlock(s.lock) | ||
end | ||
end | ||
|
||
function unlock(s::AsymmetricSemaphore) | ||
if s.nbwaiters[] > 0 | ||
unlock(s.lock) | ||
end | ||
end | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of the library does not automatically know about the existence of this file. In needs to be included from the main file
src/QuantumSavory.jl
. Given that it is a dependency for the content ofstates_registers.jl
it should probably be included before it. E.g. here:QuantumSavory.jl/src/QuantumSavory.jl
Line 82 in 46cb2f3