Page MenuHomePhabricator

Add RWCollection, a read-write locked collection with a mostly safe API
ClosedPublic

Authored by deadalnix on Nov 4 2018, 18:24.

Details

Summary

The codebase is badly lacking a read-write collection utility that promotes proper use through its API.

RWCollection cannot be manipulated directly, but through views that also hold a lock. It is possible to have several read views at once, but the collection can only be read from using them. It is possible to only hold one write view at once, and the collection can be modified using it.

Test Plan
make check

Added unit tests for the new code.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

You may also add a test to check the locking behaviour.

src/rwcollection.h
34 ↗(On Diff #5640)

Typo

schancel added inline comments.
src/rwcollection.h
62 ↗(On Diff #5640)

UpperCamelCase for methods please. GetReadView

69 ↗(On Diff #5640)

Ditto

This revision is now accepted and ready to land.Nov 6 2018, 23:22
This revision was automatically updated to reflect the committed changes.