1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5#ifndef GCHANDLETABLE_H_
6#define GCHANDLETABLE_H_
7
8#include "gcinterface.h"
9#include "objecthandle.h"
10
11class GCHandleStore : public IGCHandleStore
12{
13public:
14 virtual void Uproot();
15
16 virtual bool ContainsHandle(OBJECTHANDLE handle);
17
18 virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type);
19
20 virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type, int heapToAffinitizeTo);
21
22 virtual OBJECTHANDLE CreateHandleWithExtraInfo(Object* object, HandleType type, void* pExtraInfo);
23
24 virtual OBJECTHANDLE CreateDependentHandle(Object* primary, Object* secondary);
25
26 virtual void RelocateAsyncPinnedHandles(IGCHandleStore* pTarget, void (*clearIfCompleteCallback)(Object* object), void (*setHandle)(Object* object, OBJECTHANDLE handle));
27
28 virtual bool EnumerateAsyncPinnedHandles(async_pin_enum_fn callback, void* context);
29
30 virtual ~GCHandleStore();
31
32 HandleTableBucket _underlyingBucket;
33};
34
35extern GCHandleStore* g_gcGlobalHandleStore;
36
37class GCHandleManager : public IGCHandleManager
38{
39public:
40 virtual bool Initialize();
41
42 virtual void Shutdown();
43
44 virtual void* GetHandleContext(OBJECTHANDLE handle);
45
46 virtual IGCHandleStore* GetGlobalHandleStore();
47
48 virtual IGCHandleStore* CreateHandleStore(void* context);
49
50 virtual void DestroyHandleStore(IGCHandleStore* store);
51
52 virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, HandleType type);
53
54 virtual OBJECTHANDLE CreateDuplicateHandle(OBJECTHANDLE handle);
55
56 virtual void DestroyHandleOfType(OBJECTHANDLE handle, HandleType type);
57
58 virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle);
59
60 virtual void SetExtraInfoForHandle(OBJECTHANDLE handle, HandleType type, void* pExtraInfo);
61
62 virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle);
63
64 virtual void StoreObjectInHandle(OBJECTHANDLE handle, Object* object);
65
66 virtual bool StoreObjectInHandleIfNull(OBJECTHANDLE handle, Object* object);
67
68 virtual void SetDependentHandleSecondary(OBJECTHANDLE handle, Object* object);
69
70 virtual Object* GetDependentHandleSecondary(OBJECTHANDLE handle);
71
72 virtual Object* InterlockedCompareExchangeObjectInHandle(OBJECTHANDLE handle, Object* object, Object* comparandObject);
73
74 virtual HandleType HandleFetchType(OBJECTHANDLE handle);
75
76 virtual void TraceRefCountedHandles(HANDLESCANPROC callback, uintptr_t param1, uintptr_t param2);
77};
78
79#endif // GCHANDLETABLE_H_
80