ExpirableObject.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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. class ThreadContext;
  6. class ExpirableObject: public FinalizableObject
  7. {
  8. public:
  9. ExpirableObject(ThreadContext* threadContext);
  10. virtual void Finalize(bool isShutdown);
  11. virtual void Dispose(bool isShutdown) override;
  12. virtual void Mark(Recycler *recycler) override { AssertMsg(false, "Mark called on object that isn't TrackableObject"); }
  13. // Called when an expirable object gets expired
  14. virtual void Expire() = 0;
  15. virtual void EnterExpirableCollectMode();
  16. bool IsObjectUsed();
  17. void SetIsObjectUsed();
  18. bool SupportsExpiration()
  19. {
  20. return (GetRegistrationHandle() != nullptr);
  21. }
  22. // Used by ThreadContext
  23. void * GetRegistrationHandle();
  24. void SetRegistrationHandle(void * registrationHandle);
  25. void ClearRegistrationHandle();
  26. private:
  27. Field(intptr_t) registrationHandle;
  28. };