1 #ifndef __DALI_V8PLUGIN_GARBAGE_COLLECTOR_INTERFACE_H__
2 #define __DALI_V8PLUGIN_GARBAGE_COLLECTOR_INTERFACE_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
27 class BaseWrappedObject;
30 * @brief Tracks all Dali-wrapped objects that are used by v8.
31 * Required to delete any wrapped objects that are not cleaned up after V8 has shut down.
33 * Unfortunately the v8 garbage collection may never run while executing a script,
34 * and currently doesn't run on shutdown (for performance reasons with Chrome browser).
36 * This means we have to manually keep track of all objects, and perform our
37 * own garbage collection on shut down.
39 * For every object created:
40 * - Store a weak handle to it
41 * - Register a callback to be informed if v8 garbage collector decides it's no longer required.
42 * -- Call back is done using v8 SetWeak(), which states:
43 * "There is no guarantee as to *when* or even *if* the callback is invoked."
46 class GarbageCollectorInterface
52 * Register an object with Dali's garbage collector
53 * @param object a wrapped object
55 virtual void Register( BaseWrappedObject* object ) = 0;
58 * Un-register an object with Dali's garbage collector
59 * @param object a wrapped object
61 virtual void UnRegister( BaseWrappedObject* object ) = 0;
66 virtual void GarbageCollect() = 0;
73 GarbageCollectorInterface()
80 virtual ~GarbageCollectorInterface()
84 // Undefined copy constructor.
85 GarbageCollectorInterface( const GarbageCollectorInterface& );
87 // Undefined assignment operator.
88 GarbageCollectorInterface& operator=( const GarbageCollectorInterface& );
97 #endif // header __DALI_V8PLUGIN_GARBAGE_COLLECTOR_INTERFACE_H__