• Yi Zhang's avatar
    Record owner gettid() if TrackThreadId is enabled · 1540c39c
    Yi Zhang authored
    Summary:
    Adds a new TrackThreadId template argument to SharedMutexImpl that when enabled, expands SharedMutex from 4 to 8 bytes (still with
    4 byte alignment), and uses the extra space to record the thread ID
    of a distinguished owning thread (upgrade or exclusive lock holder).
    This dramatically simplifies debugging in some scenarios.  It adds enough
    information that we could enforce that unlock happens on the same thread
    as lock, but this diff doesn't actually add such a check.
    
    A new TrackedSharedMutex class is added for SharedMutex with lock owner thread id tracking enabled. fb_localtime is the only user for now to reduce the risk.
    
    Differential Revision: D24731513
    
    fbshipit-source-id: 6b41fb05498842224feb088b1332794281b501a9
    1540c39c
SharedMutexTest.cpp 89.3 KB