15 PSpace in thread local storage

The CSpace implementation managed to factor out an implementation that completely avoided thread local storage. Unfortunately that's not so easy with the PersistStore.

  • IPersistable is fundamental to the underlying implementation
  • IPersistable defines the method VisitPrefs
  • IPrefVisitor directly visits pref members
  • operator*() on a pref can only make sense if the associated PSpace is available in thread local storage

PSpace* GetThreadPtr<PSpace>()

Get the pointer to the PSpace in thread local storage, or returns nullptr if none has been set.


void SetThreadPtr(PSpace* pspace)

Set the pointer to the PSpace in thread local storage.


PersistStore* GetThreadPersistStore()

If a PSpace is set in thread local storage then returns the associated PersistStore, otherwise returns nullptr.