File: GcWatch.h

package info (click to toggle)
storm-lang 0.7.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,100 kB
  • sloc: ansic: 261,471; cpp: 140,438; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (40 lines) | stat: -rw-r--r-- 1,283 bytes parent folder | download
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
#pragma once

namespace storm {

	/**
	 * Location dependency declarations for objects in the GC.
	 *
	 * This object encapsulates an interface which enables users to query if an object has been
	 * moved by the GC since the last time it was accessed. This is useful when implementing hash
	 * maps for which the object's location is its key into the table. Moving the object alters this
	 * identity, and therefore destroys the hash map. Using a GcWatch to keep track of changes
	 * allows the map to detect these conditions and act accordingly.
	 *
	 * Note: Call runtime::createWatch() to create GcWatch objects.
	 */
	class GcWatch : NoCopy {
	public:
		// Add an address to be watched.
		virtual void add(const void *addr) = 0;

		// Remove an address from the watchlist.
		virtual void remove(const void *addr) = 0;

		// Clear all watched addresses.
		virtual void clear() = 0;

		// See if any object has moved. May return false positives.
		virtual bool moved() = 0;

		// See if the object has moved. May return false positives.
		virtual bool moved(const void *addr) = 0;

		// See if this object is tagged, i.e. making 'moved' always return true.
		virtual bool tagged() = 0;

		// Clone this GcWatch (and its current state).
		virtual GcWatch *clone() const = 0;
	};

}