DittoSyncKit  1.0.0-alpha4
Classes | List of all members
Ditto.SyncKit.RCHandle< T > Class Template Reference

Store an IDisposable object in a reference-counted wrapper, in a way that can be shared over FFI. More...

Detailed Description

Store an IDisposable object in a reference-counted wrapper, in a way that can be shared over FFI.

Constructing an RCHandle with an object takes ownership of that object, and the resulting RCHandle represents an initial refcount of 1. When the count drops to 0, the inner object is Dispose()d and it is invalid to perform any further retain or release operations.

The C# holder of the RCHandle may call Retain() and Release() as required to manipulate the count. It is expected that a non-permanent resource will eventually have Release() called once.

A raw pointer and corresponding retain/release functions are made available for giving to Rust. These will allow Rust to retain and use the inner GCHandle and object for as long as needed, even if the original RCHandle has previously been released and garbage collected.

Template Parameters
TClass to be kept under reference count
Type Constraints
T :System.IDisposable