xsync icon indicating copy to clipboard operation
xsync copied to clipboard

Add StampedLockFactory and ReadWriteLockFactory

Open l0s opened this issue 4 years ago • 3 comments

This adds two new factories that generate StampedLock and ReadWriteLock instances for applications that require more granular control over locking. The unit tests duplicate the verifications in XMutexFactoryImplTest and also introduce verifications specific to the synchronisation mechanisms.

Some things I considered, but did not end up implementing:

  • Create a common base test class for the common verifications used by XMutexFactoryImplTest, StampedLockFactoryTest, and ReadWriteLockFactoryTest.
  • Adding an interface and impl class for the new factories. It did not appear that multiple implementations for XMutexFactory were actually used and it was not clear to me why clients would provide a custom implementation.

I would be happy to revisit these, of course.

Addresses: #9

l0s avatar Jun 22 '20 20:06 l0s

Codecov Report

Merging #10 into master will increase coverage by 0.15%. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #10      +/-   ##
============================================
+ Coverage     99.16%   99.32%   +0.15%     
- Complexity       37       51      +14     
============================================
  Files             4        6       +2     
  Lines           120      148      +28     
  Branches         10       10              
============================================
+ Hits            119      147      +28     
  Partials          1        1              
Impacted Files Coverage Δ Complexity Δ
...java/com/antkorwin/xsync/ReadWriteLockFactory.java 100.00% <100.00%> (ø) 8.00 <8.00> (?)
...n/java/com/antkorwin/xsync/StampedLockFactory.java 100.00% <100.00%> (ø) 6.00 <6.00> (?)

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 5a1bb6c...a2bfe30. Read the comment docs.

codecov-commenter avatar Jun 22 '20 20:06 codecov-commenter

As an aside, while developing this, I noticed that the project builds fine with Java 9, but fails with Java 10 or higher. It produces this error during the testCompile phase:

java.lang.ClassNotFoundException: com.sun.tools.javac.code.TypeTags

l0s avatar Jun 22 '20 20:06 l0s

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar May 01 '23 23:05 sonarqubecloud[bot]