Add lld-parking-lot module: thread-safe parking lot with Strategy, Observer and CAS-based spot claiming, 10 tests incl. 64-thread race

This commit is contained in:
2026-10-22 08:01:55 +00:00
parent d4b3a63615
commit a5fbf45971
24 changed files with 670 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
== 1. entering and leaving ==
board: {SMALL=1, MEDIUM=2, LARGE=1}
board: {SMALL=1, MEDIUM=1, LARGE=1}
board: {SMALL=1, MEDIUM=1, LARGE=0}
bike -> F0-1, car -> F0-2, truck -> F0-3
board: {SMALL=1, MEDIUM=2, LARGE=0}
car stayed 130 min, fee = 60
== 2. failures ==
second MH03-TRK : MH03-TRK is already inside the lot
another truck : no free spot for TRUCK MH04-TRK
reused ticket : unknown or already used ticket T-2
== 3. the strategy decides where the motorcycle goes ==
NearestFirstStrategy puts a motorcycle in F0-1
BestFitStrategy puts a motorcycle in F1-1
@@ -0,0 +1,11 @@
PASS truckIsRejectedWhenOnlyMediumSpotsAreFree
PASS listenersSeeEveryChange
PASS samePlateCannotBeInsideTwice
PASS bestFitKeepsLargeSpotsFreeForTrucks
PASS concurrentDuplicatePlateAdmitsExactlyOne
PASS failedParkDoesNotLeaveThePlateReserved
PASS nearestFirstTakesTheFirstFreeSpotThatFits
PASS feeRoundsPartialHoursUpAndHasAGracePeriod
PASS concurrentParkingNeverDoubleBooksASpot
PASS exitFreesTheSpotAndTheTicketIsSingleUse
10 tests, 0 failures