slot 0.0.1
A real time UI render framework
载入中...
搜索中...
未找到
Public 成员函数 | Private 属性 | 所有成员列表
facebook::yoga::vanillajni::ScopedLocalRef< T > 模板类 参考

#include <ScopedLocalRef.h>

facebook::yoga::vanillajni::ScopedLocalRef< T > 的协作图:
Collaboration graph
[图例]

Public 成员函数

 ScopedLocalRef (JNIEnv *env, T localRef)
 
 ScopedLocalRef (JNIEnv *env)
 
 ScopedLocalRef (ScopedLocalRef &&s) noexcept
 
ScopedLocalRefoperator= (ScopedLocalRef &&s) noexcept
 
 ~ScopedLocalRef ()
 
void reset (T ptr=NULL)
 
release ()
 
get () const
 
 operator bool () const
 
 ScopedLocalRef (const ScopedLocalRef &ref)=delete
 
ScopedLocalRefoperator= (const ScopedLocalRef &other)=delete
 

Private 属性

JNIEnvmEnv
 
mLocalRef
 

详细描述

template<typename T>
class facebook::yoga::vanillajni::ScopedLocalRef< T >

ScopedLocalRef is a sort of smart reference that allows us to control the lifespan of a JNI local reference.

This class is designed so that when a ScopedLocalRef goes out of scope, its destructor will delete -JNIEnv->DeleteLocalRef()- the underlying JNI reference.

This class should be used to wrap all the local references that JNI gives us other than those that are passed to native methods at invocation time. The idea behind this is that in JNI we should be very explicit about the lifespan of local references. Local references can quickly get out of control, and the developer should always be very aware of the lifespan of each local reference that is created in JNI so that leaks are prevented.

This class is very explicit in its behavior, and it does not allow to perform unexpected conversions or unexpected ownership transfer. In practice, this class acts as a unique pointer where the underlying JNI reference can have one and just one owner. Transferring ownership is allowed but it is an explicit operation (implemented via move semantics and also via explicitly API calls).

As with standard JNI local references it is not a valid operation to keep a reference around between different native method calls.

构造及析构函数说明

◆ ScopedLocalRef() [1/4]

template<typename T >
facebook::yoga::vanillajni::ScopedLocalRef< T >::ScopedLocalRef ( JNIEnv * env,
T localRef )
inline

Constructs a ScopedLocalRef with a JNI local reference.

参数
localRefthe local reference to wrap. Can be NULL.

◆ ScopedLocalRef() [2/4]

template<typename T >
facebook::yoga::vanillajni::ScopedLocalRef< T >::ScopedLocalRef ( JNIEnv * env)
inlineexplicit

Equivalent to ScopedLocalRef(env, NULL)

◆ ScopedLocalRef() [3/4]

template<typename T >
facebook::yoga::vanillajni::ScopedLocalRef< T >::ScopedLocalRef ( ScopedLocalRef< T > && s)
inlinenoexcept

Move construction is allowed.

◆ ~ScopedLocalRef()

template<typename T >
facebook::yoga::vanillajni::ScopedLocalRef< T >::~ScopedLocalRef ( )
inline
函数调用图:

◆ ScopedLocalRef() [4/4]

template<typename T >
facebook::yoga::vanillajni::ScopedLocalRef< T >::ScopedLocalRef ( const ScopedLocalRef< T > & ref)
delete

成员函数说明

◆ get()

template<typename T >
T facebook::yoga::vanillajni::ScopedLocalRef< T >::get ( ) const
inline

Returns the underlying JNI local reference.

这是这个函数的调用关系图:

◆ operator bool()

template<typename T >
facebook::yoga::vanillajni::ScopedLocalRef< T >::operator bool ( ) const
inline

Returns true if the underlying JNI reference is not NULL.

◆ operator=() [1/2]

template<typename T >
ScopedLocalRef & facebook::yoga::vanillajni::ScopedLocalRef< T >::operator= ( const ScopedLocalRef< T > & other)
delete

◆ operator=() [2/2]

template<typename T >
ScopedLocalRef & facebook::yoga::vanillajni::ScopedLocalRef< T >::operator= ( ScopedLocalRef< T > && s)
inlinenoexcept

Move assignment is allowed.

函数调用图:

◆ release()

template<typename T >
T facebook::yoga::vanillajni::ScopedLocalRef< T >::release ( )
inline

Makes this ScopedLocalRef not own the underlying JNI local reference. After calling this method, the ScopedLocalRef will not delete the JNI local reference when the ScopedLocalRef goes out of scope.

◆ reset()

template<typename T >
void facebook::yoga::vanillajni::ScopedLocalRef< T >::reset ( T ptr = NULL)
inline

Deletes the currently held reference and reassigns a new one to the ScopedLocalRef.

这是这个函数的调用关系图:

类成员变量说明

◆ mEnv

template<typename T >
JNIEnv* facebook::yoga::vanillajni::ScopedLocalRef< T >::mEnv
private

◆ mLocalRef

template<typename T >
T facebook::yoga::vanillajni::ScopedLocalRef< T >::mLocalRef
private

该类的文档由以下文件生成: