From 5a65b2bd85abeb444218f2b0bf751518847bd632 Mon Sep 17 00:00:00 2001 From: Tudor Bosman Date: Fri, 19 Dec 2014 18:33:14 -0800 Subject: [PATCH] Add comment explaining that RWTicketSpinLock<..., true> is not reentrant Test Plan: no, it's a comment Reviewed By: zanfur@fb.com Subscribers: folly-diffs@ FB internal diff: D1752850 Tasks: 5823969 Signature: t1:1752850:1419043661:673c68c0daad28b3fde9709e767b528b0dec8ad1 --- folly/RWSpinLock.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/folly/RWSpinLock.h b/folly/RWSpinLock.h index f47def60..c6bec8df 100644 --- a/folly/RWSpinLock.h +++ b/folly/RWSpinLock.h @@ -46,6 +46,18 @@ * RWTicketSpinLock<64> only allows up to 2^16 - 1 concurrent * readers and writers. * + * RWTicketSpinLock<..., true> (kFavorWriter = true, that is, strict + * writer priority) is NOT reentrant, even for lock_shared(). + * + * The lock will not grant any new shared (read) accesses while a thread + * attempting to acquire the lock in write mode is blocked. (That is, + * if the lock is held in shared mode by N threads, and a thread attempts + * to acquire it in write mode, no one else can acquire it in shared mode + * until these N threads release the lock and then the blocked thread + * acquires and releases the exclusive lock.) This also applies for + * attempts to reacquire the lock in shared mode by threads that already + * hold it in shared mode, making the lock non-reentrant. + * * RWSpinLock handles 2^30 - 1 concurrent readers. * * @author Xin Liu -- 2.34.1