remotemono
|
#include <RMonoHandle_Def.h>
Public Types | |
typedef RMonoHandle< rmono_gchandle, &RMonoObjectHandleDelete, REMOTEMONO_GCHANDLE_INVALID > | Base |
typedef RMonoObjectHandle< RawPtrT > | Self |
typedef RawPtrT | RawPtr |
![]() | |
typedef rmono_gchandle | HandleType |
typedef RMonoHandle< HandleType, deleter, invalidHandle > | Self |
Public Member Functions | |
RMonoObjectHandle () | |
RMonoObjectHandle (std::nullptr_t) | |
RMonoObjectHandle (rmono_gchandle gchandle, RMonoAPIBase *mono, bool owned=true) | |
RMonoObjectHandle (const Self &other) | |
RMonoObjectHandle (Self &&other) | |
Self & | operator= (const Self &other) |
Self & | operator= (Self &&other) |
bool | operator== (const Self &other) const |
bool | operator!= (const Self &other) const |
Self | pin () const |
Self | clone () const |
RawPtr | raw () const |
![]() | |
RMonoHandle () | |
RMonoHandle (std::nullptr_t) | |
RMonoHandle (HandleType handle, RMonoAPIBase *mono, bool owned) | |
RMonoHandle (const Self &other) | |
RMonoHandle (Self &&other) | |
Self & | operator= (const Self &other) |
Self & | operator= (Self &&other) |
bool | operator== (const Self &other) const |
bool | operator!= (const Self &other) const |
HandleType | operator* () const |
RMonoAPIBase * | getMonoAPI () |
bool | takeOwnership () |
void | reset () |
bool | isValid () const |
bool | isNull () const |
operator bool () const | |
Additional Inherited Members | |
![]() | |
std::shared_ptr< Data > | d |
A wrapper around MonoObject* and derived types like MonoString*, MonoException* etc.
This class does not hold the raw remote pointer, but holds a rmono_gchandle (created by mono_gchandle_new()) to it. Storing raw remote pointers to such objects in the local process is dangerous, because these objects are managed by Mono's garbage collector, so they could be deleted at any moment as soon as the remote process itself does not hold references to it anymore. And even if the remote process does still hold a reference to it, the GC is allowed to move the objects in memory at any time. There are only three situations in which it is safe to hold references to such objects in native code:
The first option can be ruled out for RemoteMono, because we want to keep references in the local process, not just on the remote. The third option should be strongly avoided, because it will very quickly lead to severe performance degradation because the GC can't do its job properly. This is why RemoteMono always keeps references to MonoObject* as rmono_gchandle.
It is possible to get the raw MonoObject* by calling raw(), but note that this is only safe to use if the RMonoObjectHandle has been pinned by calling pin(), and only as long as that pinned RMonoObjectHandle remains valid.
|
inline |
Constructs a null pointer handle.
|
inline |
Constructs a null pointer handle
|
inline |
Constructs an RMonoObjectHandle from a rmono_gchandle.
gchandle | The GC handle obtained from the remote process by mono_gchandle_new(). |
mono | The RMonoAPI instance that the object belongs to |
owned | true if the handle should own the rmono_gchandle and free it using mono_gchandle_free() when the internal shared pointer expires. |
|
inline |
Copy constructor.
|
inline |
Move constructor.
|
inline |
Return a new RMonoObjectHandle with a separate rmono_gchandle referencing the same raw pointer. The new handle will not be pinned.
|
inline |
Returns true if the two RMonoObjectHandle instances refer to different raw remote pointers.
|
inline |
Assignment operator.
|
inline |
Move-assignment operator
|
inline |
Returns true if the two RMonoObjectHandle instances refer to the same raw remote pointer, i.e. the same remote MonoObject. Note that this does not compare the rmono_gchandles: Two different GC handles may refer to the same MonoObject, and this method would return true in those cases.
|
inline |
Return a new RMonoObjectHandle pointing to the same object that this handle points to, but pinned down.
|
inline |
Return the raw remote pointer behind this RMonoObjectHandle. This calls mono_gchandle_get_target(). Note that this the raw pointer is only safe to use as long as a pinned GC handle to it exists somewhere.