C# Class Microsoft.Isam.Esent.Interop.CallbackWrappers

A collection of wrapped callbacks. This is used when the wrapped callback can be garbage collected. The wrappers should be removed from the collection when the callback is collected.

Removing the wrappers can lead to crashes. In this case we trust the client code to keep its callback alive until ESENT doesn't need it any more. Once the wrapped callback is garbage collected we allow the wrapper to be collected as well. If ESENT subsequently uses the callback there will be a crash.

The reason this is hard to deal with is that the lifetime of a JET_CALLBACK isn't very clear. Table callbacks can stick around until the table meta-data is purged, while a JetDefragment callback can be used until defrag ends. On the other hand, keeping the callback wrapper alive indefinitely could lead to unbounded memory use.

Mostra file Open project: ayende/managed-esent Class Usage Examples

Public Methods

Method Description
Add ( JET_CALLBACK callback ) : JetCallbackWrapper

Wrap a callback and returns its wrapper. If the callback is already wrapped then the existing wrapper is returned.

Collect ( ) : void

Go through the collection of callback wrappers and remove any dead callbacks.

Private Methods

Method Description
TryFindWrapperFor ( JET_CALLBACK callback, JetCallbackWrapper &wrapper ) : bool

Look in the list of callback wrappers to see if there is already an entry for this callback.

Method Details

Add() public method

Wrap a callback and returns its wrapper. If the callback is already wrapped then the existing wrapper is returned.
public Add ( JET_CALLBACK callback ) : JetCallbackWrapper
callback JET_CALLBACK The callback to add.
return JetCallbackWrapper

Collect() public method

Go through the collection of callback wrappers and remove any dead callbacks.
public Collect ( ) : void
return void