ThreadBoundThreadContextManager.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. class ThreadContextManagerBase
  7. {
  8. protected:
  9. static void ShutdownThreadContext(
  10. ThreadContext* threadContext, bool deleteThreadContext = true);
  11. };
  12. class ThreadBoundThreadContextManager : public ThreadContextManagerBase
  13. {
  14. friend class ThreadContext;
  15. public:
  16. typedef DList<ThreadContextTLSEntry *, HeapAllocator> EntryList;
  17. static ThreadContext * EnsureContextForCurrentThread();
  18. static void DestroyContextAndEntryForCurrentThread();
  19. static void DestroyAllContexts();
  20. static void DestroyAllContextsAndEntries(bool shouldDeleteCurrentTlsEntry);
  21. static JsUtil::JobProcessor * GetSharedJobProcessor();
  22. private:
  23. static EntryList entries;
  24. #if ENABLE_BACKGROUND_JOB_PROCESSOR
  25. static JsUtil::BackgroundJobProcessor * s_sharedJobProcessor;
  26. #endif
  27. static CriticalSection s_sharedJobProcessorCreationLock;
  28. };
  29. class RentalThreadContextManager : public ThreadContextManagerBase
  30. {
  31. public:
  32. static void DestroyThreadContext(ThreadContext* threadContext);
  33. };