Welcome to mirror list, hosted at ThFree Co, Russian Federation.

objectlist.h « vm « coreclr « src - github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4542c890f800c871effb89d6e6a4e4f247a399df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.



#ifndef __objectlist_h__
#define __objectlist_h__


#include "arraylist.h"
#include "holder.h"

#define INVALID_COMPRESSEDSTACK_INDEX ((DWORD)-1)
#ifdef _DEBUG
#define FREE_LIST_SIZE 128
#else
#define FREE_LIST_SIZE 1024
#endif



class ObjectList
{
public:
	class Iterator
    	{
		friend class ObjectList;

		  protected:
		   ArrayList::Iterator _iter;

		  public:

		PTR_VOID GetElement()
		{
			LIMITED_METHOD_CONTRACT;
			PTR_VOID ptr = _iter.GetElement();
			if (((DWORD)(size_t)(dac_cast<TADDR>(ptr)) & 0x1) == 0)
			{
				return ptr;
			}
			else
			{
				return NULL;
			}
		}

		DWORD GetIndex()
		{
			LIMITED_METHOD_CONTRACT;
			return _iter.GetIndex();
		}

		BOOL Next()
		{
			LIMITED_METHOD_CONTRACT;
			return _iter.Next();
		}
   	};

	ObjectList() DAC_EMPTY();

	DWORD AddToList( PVOID ptr );
	void RemoveFromList( PVOID ptr );
	void RemoveFromList( DWORD index, PVOID ptr );
	PVOID Get( DWORD index );

	ObjectList::Iterator Iterate()
	{
		LIMITED_METHOD_CONTRACT;
		ObjectList::Iterator i;
		i._iter = this->allEntries_.Iterate();
		return i;
	}

private:
    ArrayList allEntries_;
    DWORD freeIndexHead_;
    Crst listLock_;
};

class UnsynchronizedBlockAllocator
{
public:
    UnsynchronizedBlockAllocator( size_t blockSize );
    ~UnsynchronizedBlockAllocator( void );

    PVOID Allocate( size_t size );

private:
    ArrayList blockList_;

    size_t blockSize_;
    size_t offset_;
    DWORD index_;

};

#endif // __objectlist_h__