track total size of static array and Unit/Class/Func
[hiphop-php.git] / hphp / runtime / base / weakref-data.h
blob7e78f88497c6289c2dd90ddbbe078b790070f852
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
16 #ifndef incl_HPHP_WEAKREF_DATA_H_
17 #define incl_HPHP_WEAKREF_DATA_H_
19 #include "hphp/runtime/base/req-memory.h"
20 #include "hphp/runtime/base/typed-value.h"
22 #include "hphp/util/type-scan.h"
24 namespace HPHP {
26 struct Object;
28 // A single WeakRefData is shared between all WeakRefs to a given refcounted
29 // object.
30 struct WeakRefData {
31 TypedValue pointee; // Object being weakly referenced.
32 TYPE_SCAN_CUSTOM() {
33 scanner.weak(this);
36 // Invalidate WeakRefData associated with a refcounted object.
37 static void invalidateWeakRef(uintptr_t ptr);
39 // Create or find WeakRefData for a given refcounted object.
40 static req::shared_ptr<WeakRefData> forObject(Object obj);
42 ~WeakRefData();
43 explicit WeakRefData(const TypedValue& tv): pointee(tv) {}
45 bool isValid() const;
48 void weakref_cleanup();
50 } // namespace HPHP
51 #endif // incl_HPHP_WEAKREF_DATA_H_