| v8.h | | v8.h | |
| | | | |
| skipping to change at line 1582 | | skipping to change at line 1582 | |
| */ | | */ | |
| V8EXPORT void SetIndexedPropertiesToExternalArrayData( | | V8EXPORT void SetIndexedPropertiesToExternalArrayData( | |
| void* data, | | void* data, | |
| ExternalArrayType array_type, | | ExternalArrayType array_type, | |
| int number_of_elements); | | int number_of_elements); | |
| V8EXPORT bool HasIndexedPropertiesInExternalArrayData(); | | V8EXPORT bool HasIndexedPropertiesInExternalArrayData(); | |
| V8EXPORT void* GetIndexedPropertiesExternalArrayData(); | | V8EXPORT void* GetIndexedPropertiesExternalArrayData(); | |
| V8EXPORT ExternalArrayType GetIndexedPropertiesExternalArrayDataType(); | | V8EXPORT ExternalArrayType GetIndexedPropertiesExternalArrayDataType(); | |
| V8EXPORT int GetIndexedPropertiesExternalArrayDataLength(); | | V8EXPORT int GetIndexedPropertiesExternalArrayDataLength(); | |
| | | | |
|
| | | /** | |
| | | * Call an Object as a function if a callback is set by the | |
| | | * ObjectTemplate::SetCallAsFunctionHandler method. | |
| | | */ | |
| | | V8EXPORT Local<Value> CallAsFunction(Handle<Object> recv, | |
| | | int argc, | |
| | | Handle<Value> argv[]); | |
| | | | |
| | | /** | |
| | | * Call an Object as a consturctor if a callback is set by the | |
| | | * ObjectTemplate::SetCallAsFunctionHandler method. | |
| | | * Note: This method behaves like the Function::NewInstance method. | |
| | | */ | |
| | | V8EXPORT Local<Value> CallAsConstructor(int argc, | |
| | | Handle<Value> argv[]); | |
| | | | |
| V8EXPORT static Local<Object> New(); | | V8EXPORT static Local<Object> New(); | |
| static inline Object* Cast(Value* obj); | | static inline Object* Cast(Value* obj); | |
| private: | | private: | |
| V8EXPORT Object(); | | V8EXPORT Object(); | |
| V8EXPORT static void CheckCast(Value* obj); | | V8EXPORT static void CheckCast(Value* obj); | |
| V8EXPORT Local<Value> CheckedGetInternalField(int index); | | V8EXPORT Local<Value> CheckedGetInternalField(int index); | |
| V8EXPORT void* SlowGetPointerFromInternalField(int index); | | V8EXPORT void* SlowGetPointerFromInternalField(int index); | |
| | | | |
| /** | | /** | |
| * If quick access to the internal field is possible this method | | * If quick access to the internal field is possible this method | |
| | | | |
| skipping to change at line 3316 | | skipping to change at line 3332 | |
| | | | |
| /** | | /** | |
| * Multiple threads in V8 are allowed, but only one thread at a time | | * Multiple threads in V8 are allowed, but only one thread at a time | |
| * is allowed to use any given V8 isolate. See Isolate class | | * is allowed to use any given V8 isolate. See Isolate class | |
| * comments. The definition of 'using V8 isolate' includes | | * comments. The definition of 'using V8 isolate' includes | |
| * accessing handles or holding onto object pointers obtained | | * accessing handles or holding onto object pointers obtained | |
| * from V8 handles while in the particular V8 isolate. It is up | | * from V8 handles while in the particular V8 isolate. It is up | |
| * to the user of V8 to ensure (perhaps with locking) that this | | * to the user of V8 to ensure (perhaps with locking) that this | |
| * constraint is not violated. | | * constraint is not violated. | |
| * | | * | |
|
| * More then one thread and multiple V8 isolates can be used | | * v8::Locker is a scoped lock object. While it's | |
| * without any locking if each isolate is created and accessed | | * active (i.e. between its construction and destruction) the current threa | |
| * by a single thread only. For example, one thread can use | | d is | |
| * multiple isolates or multiple threads can each create and run | | * allowed to use the locked isolate. V8 guarantees that an isolate can be | |
| * their own isolate. | | locked | |
| * | | * by at most one thread at any time. In other words, the scope of a v8::Lo | |
| * If you wish to start using V8 isolate in more then one thread | | cker is | |
| * you can do this by constructing a v8::Locker object to guard | | * a critical section. | |
| * access to the isolate. After the code using V8 has completed | | | |
| * for the current thread you can call the destructor. This can | | | |
| * be combined with C++ scope-based construction as follows | | | |
| * (assumes the default isolate that is used if not specified as | | | |
| * a parameter for the Locker): | | | |
| * | | * | |
|
| * \code | | * Sample usage: | |
| | | * \code | |
| * ... | | * ... | |
| * { | | * { | |
|
| * v8::Locker locker; | | * v8::Locker locker(isolate); | |
| | | * v8::Isolate::Scope isolate_scope(isolate); | |
| * ... | | * ... | |
|
| * // Code using V8 goes here. | | * // Code using V8 and isolate goes here. | |
| * ... | | * ... | |
| * } // Destructor called here | | * } // Destructor called here | |
| * \endcode | | * \endcode | |
| * | | * | |
| * If you wish to stop using V8 in a thread A you can do this by either | | * If you wish to stop using V8 in a thread A you can do this by either | |
| * by destroying the v8::Locker object as above or by constructing a | | * by destroying the v8::Locker object as above or by constructing a | |
| * v8::Unlocker object: | | * v8::Unlocker object: | |
| * | | * | |
| * \code | | * \code | |
| * { | | * { | |
|
| * v8::Unlocker unlocker; | | * isolate->Exit(); | |
| | | * v8::Unlocker unlocker(isolate); | |
| * ... | | * ... | |
| * // Code not using V8 goes here while V8 can run in another thread. | | * // Code not using V8 goes here while V8 can run in another thread. | |
| * ... | | * ... | |
| * } // Destructor called here. | | * } // Destructor called here. | |
|
| | | * isolate->Enter(); | |
| * \endcode | | * \endcode | |
| * | | * | |
| * The Unlocker object is intended for use in a long-running callback | | * The Unlocker object is intended for use in a long-running callback | |
| * from V8, where you want to release the V8 lock for other threads to | | * from V8, where you want to release the V8 lock for other threads to | |
| * use. | | * use. | |
| * | | * | |
| * The v8::Locker is a recursive lock. That is, you can lock more than | | * The v8::Locker is a recursive lock. That is, you can lock more than | |
| * once in a given thread. This can be useful if you have code that can | | * once in a given thread. This can be useful if you have code that can | |
| * be called either from code that holds the lock or from code that does | | * be called either from code that holds the lock or from code that does | |
| * not. The Unlocker is not recursive so you can not have several | | * not. The Unlocker is not recursive so you can not have several | |
| * Unlockers on the stack at once, and you can not use an Unlocker in a | | * Unlockers on the stack at once, and you can not use an Unlocker in a | |
| * thread that is not inside a Locker's scope. | | * thread that is not inside a Locker's scope. | |
| * | | * | |
| * An unlocker will unlock several lockers if it has to and reinstate | | * An unlocker will unlock several lockers if it has to and reinstate | |
| * the correct depth of locking on its destruction. eg.: | | * the correct depth of locking on its destruction. eg.: | |
| * | | * | |
| * \code | | * \code | |
| * // V8 not locked. | | * // V8 not locked. | |
| * { | | * { | |
|
| * v8::Locker locker; | | * v8::Locker locker(isolate); | |
| | | * Isolate::Scope isolate_scope(isolate); | |
| * // V8 locked. | | * // V8 locked. | |
| * { | | * { | |
|
| * v8::Locker another_locker; | | * v8::Locker another_locker(isolate); | |
| * // V8 still locked (2 levels). | | * // V8 still locked (2 levels). | |
| * { | | * { | |
|
| * v8::Unlocker unlocker; | | * isolate->Exit(); | |
| | | * v8::Unlocker unlocker(isolate); | |
| * // V8 not locked. | | * // V8 not locked. | |
| * } | | * } | |
|
| | | * isolate->Enter(); | |
| * // V8 locked again (2 levels). | | * // V8 locked again (2 levels). | |
| * } | | * } | |
| * // V8 still locked (1 level). | | * // V8 still locked (1 level). | |
| * } | | * } | |
| * // V8 Now no longer locked. | | * // V8 Now no longer locked. | |
| * \endcode | | * \endcode | |
|
| | | * | |
| | | * | |
| */ | | */ | |
| class V8EXPORT Unlocker { | | class V8EXPORT Unlocker { | |
| public: | | public: | |
|
| Unlocker(); | | /** | |
| | | * Initialize Unlocker for a given Isolate. NULL means default isolate. | |
| | | */ | |
| | | explicit Unlocker(Isolate* isolate = NULL); | |
| ~Unlocker(); | | ~Unlocker(); | |
|
| | | private: | |
| | | internal::Isolate* isolate_; | |
| }; | | }; | |
| | | | |
| class V8EXPORT Locker { | | class V8EXPORT Locker { | |
| public: | | public: | |
|
| Locker(); | | /** | |
| | | * Initialize Locker for a given Isolate. NULL means default isolate. | |
| | | */ | |
| | | explicit Locker(Isolate* isolate = NULL); | |
| ~Locker(); | | ~Locker(); | |
| | | | |
| /** | | /** | |
| * Start preemption. | | * Start preemption. | |
| * | | * | |
| * When preemption is started, a timer is fired every n milli seconds | | * When preemption is started, a timer is fired every n milli seconds | |
| * that will switch between multiple threads that are in contention | | * that will switch between multiple threads that are in contention | |
| * for the V8 lock. | | * for the V8 lock. | |
| */ | | */ | |
| static void StartPreemption(int every_n_ms); | | static void StartPreemption(int every_n_ms); | |
| | | | |
| /** | | /** | |
| * Stop preemption. | | * Stop preemption. | |
| */ | | */ | |
| static void StopPreemption(); | | static void StopPreemption(); | |
| | | | |
| /** | | /** | |
|
| * Returns whether or not the locker is locked by the current thread. | | * Returns whether or not the locker for a given isolate, or default isol | |
| | | ate if NULL is given, | |
| | | * is locked by the current thread. | |
| */ | | */ | |
|
| static bool IsLocked(); | | static bool IsLocked(Isolate* isolate = NULL); | |
| | | | |
| /** | | /** | |
| * Returns whether v8::Locker is being used by this V8 instance. | | * Returns whether v8::Locker is being used by this V8 instance. | |
| */ | | */ | |
| static bool IsActive() { return active_; } | | static bool IsActive() { return active_; } | |
| | | | |
| private: | | private: | |
| bool has_lock_; | | bool has_lock_; | |
| bool top_level_; | | bool top_level_; | |
|
| | | internal::Isolate* isolate_; | |
| | | | |
| static bool active_; | | static bool active_; | |
| | | | |
| // Disallow copying and assigning. | | // Disallow copying and assigning. | |
| Locker(const Locker&); | | Locker(const Locker&); | |
| void operator=(const Locker&); | | void operator=(const Locker&); | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * An interface for exporting data from V8, using "push" model. | | * An interface for exporting data from V8, using "push" model. | |
| | | | |
End of changes. 18 change blocks. |
| 24 lines changed or deleted | | 55 lines changed or added | |
|