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 multi-thread support #26

Merged
merged 3 commits into from
Dec 20, 2019
Merged

Conversation

xcaptain
Copy link
Contributor

@xcaptain xcaptain commented Dec 20, 2019

The original version uses Rc, RefCell and HashMap which are not shareable between threads.

This commit replaced Rc with Arc, RefCell with RwLock and manually deal with locks with read().unwrap() and write().unwrap(), a simple test test_role_api_threads shows how to operate casbin in a thread and then sync to other threads.

…ead safety

added some tests to demostrate how to use casbin with multiple thread
clippy is much more strict than before
@codecov
Copy link

codecov bot commented Dec 20, 2019

Codecov Report

Merging #26 into master will increase coverage by 1.15%.
The diff coverage is 70.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #26      +/-   ##
==========================================
+ Coverage   84.22%   85.38%   +1.15%     
==========================================
  Files           4       12       +8     
  Lines         279     1889    +1610     
==========================================
+ Hits          235     1613    +1378     
- Misses         44      276     +232
Impacted Files Coverage Δ
src/effector.rs 70.58% <ø> (ø)
src/enforcer.rs 75% <ø> (ø)
src/rbac/role_manager.rs 100% <ø> (ø) ⬆️
src/rbac/default_role_manager.rs 92.99% <100%> (+0.43%) ⬆️
src/model.rs 94.65% <100%> (ø)
src/rbac_api.rs 84.82% <64.77%> (ø)
src/management_api.rs 90.65% <0%> (ø)
src/errors.rs 0% <0%> (ø)
src/internal_api.rs 81.48% <0%> (ø)
... and 4 more

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 b70fbda...03980b2. Read the comment docs.

@hsluoyz
Copy link
Member

hsluoyz commented Dec 20, 2019

Merged.

@hsluoyz hsluoyz merged commit ff40845 into casbin:master Dec 20, 2019
@xcaptain xcaptain mentioned this pull request Dec 21, 2019
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