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 GetWithDefault #1762

Merged
merged 1 commit into from
Oct 6, 2017
Merged

Conversation

ChrisJefferson
Copy link
Contributor

GetWithDefault provides a way of checking if an index in a list
is bound, and the value if the index is bound, as one function call.

It is particularly useful in weak pointer lists and atomic lists,
where there is a race condition between checking if an element is
bound, and then reading it's value.

This removes the very recently added method CHECKED_GET_ATOMIC_LIST, as it is now subsumed into this general method.

GetWithDefault provides a way of checking if an index in a list
is bound, and the value if the index is bound, as one function call.

It is particularly useful in weak pointer lists and atomic lists,
where there is a race condition between checking if an element is
bound, and then reading it's value.
@codecov
Copy link

codecov bot commented Oct 3, 2017

Codecov Report

Merging #1762 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1762      +/-   ##
==========================================
+ Coverage   60.92%   60.93%   +<.01%     
==========================================
  Files         997      997              
  Lines      301950   301970      +20     
  Branches    13036    13040       +4     
==========================================
+ Hits       183968   184007      +39     
+ Misses     115333   115320      -13     
+ Partials     2649     2643       -6
Impacted Files Coverage Δ
lib/hpc/thread1.g 68.18% <ø> (-1.82%) ⬇️
src/hpc/aobjects.c 62.79% <100%> (+0.34%) ⬆️
src/weakptr.c 82.67% <100%> (+0.41%) ⬆️
src/lists.c 56.06% <100%> (+0.97%) ⬆️
src/lists.h 100% <100%> (ø) ⬆️
src/hpc/thread.c 46.64% <0%> (-0.2%) ⬇️
src/funcs.c 71.82% <0%> (ø) ⬆️
src/stats.c 73.97% <0%> (+0.27%) ⬆️
src/hpc/threadapi.c 34.74% <0%> (+0.28%) ⬆️
src/hpc/traverse.c 78.21% <0%> (+0.3%) ⬆️
... and 2 more

Copy link
Member

@sebasguts sebasguts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this will save a lot of if's when using weak pointers.

I would suggest changing the manual entry for retrieving an element from a weak pointer list to use this command as suggested way to get elements from the weak pointer list.

@markuspf markuspf merged commit 5594dbb into gap-system:master Oct 6, 2017
@ChrisJefferson ChrisJefferson deleted the checked-get branch November 6, 2017 12:44
@olexandr-konovalov olexandr-konovalov added this to the GAP 4.9.0 milestone Jan 22, 2018
@olexandr-konovalov olexandr-konovalov added the release notes: added PRs introducing changes that have since been mentioned in the release notes label Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: added PRs introducing changes that have since been mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants