public unsafe ComparatorBase(string name = null, IntPtr state = default(IntPtr)) { Name = name ?? GetType().FullName; _destroy = s => this.Destroy(s); Handle = Native.Instance.rocksdb_comparator_create( state: IntPtr.Zero, destructor: CurrentFramework.GetFunctionPointerForDelegate(_destroy), compare: CurrentFramework.GetFunctionPointerForDelegate <CompareFunc>(Compare), getName: CurrentFramework.GetFunctionPointerForDelegate <GetNameFunc>(GetName) ); }
public Pool(T sample, CreateFunc createFunc, DestroyFunc destroyFunc, ActivateFunc activateFunc, DeactivateFunc deactivateFunc, int initialSize = 100) { m_sample = sample; m_create = createFunc; m_destroy = destroyFunc; m_activate = activateFunc; m_deactivate = deactivateFunc; var go = sample as GameObject; if (go) { m_parent = new GameObject(go.name + "-Pool"); } Grow(initialSize); }
public void Clear(DestroyFunc pDestroyer = null) { #if !DISABLE_POOLING Debugger.Assert(GetPoolSize() == GetFreeObjectCount()); if (pDestroyer != null) { foreach (var obj in _objectQueue) { pDestroyer(this, obj); } } _objectQueue.Clear(); _nPoolSize = 0; #endif }
public void Clear(DestroyFunc pDestroyer = null) { #if !DISABLE_POOLING Debugger.Assert(GetPoolSize() == GetFreeObjectCount()); if (pDestroyer != null) { int nSize = GetFreeObjectCount(); for (int i = 0; i < nSize; ++i) { pDestroyer(this, _arrObjectSlots[i]); } } _arrObjectSlots = new T[0]; _nPoolSize = 0; _iCursor = -1; #endif }
public void LoadFunctions() { IntPtr funcAddr; if (libLoader.LibraryLoaded) { // fetch an address of a function // set the corresponding field if funcAddr is not null funcAddr = libLoader.GetFuncAddr("Analysis_CreateTimeSeries"); if (funcAddr != IntPtr.Zero) { CreateTimeSeries = Marshal.GetDelegateForFunctionPointer( funcAddr, typeof(CreateTimeSeriesFunc)) as CreateTimeSeriesFunc; } funcAddr = libLoader.GetFuncAddr("Analysis_DestroyTimeSeries"); if (funcAddr != IntPtr.Zero) { DestroyTimeSeries = Marshal.GetDelegateForFunctionPointer( funcAddr, typeof(DestroyFunc)) as DestroyFunc; } funcAddr = libLoader.GetFuncAddr("Analysis_CreateDetector"); if (funcAddr != IntPtr.Zero) { CreateDetector = Marshal.GetDelegateForFunctionPointer( funcAddr, typeof(CreateDetectorFunc)) as CreateDetectorFunc; } funcAddr = libLoader.GetFuncAddr("Analysis_DestroyDetector"); if (funcAddr != IntPtr.Zero) { DestroyDetector = Marshal.GetDelegateForFunctionPointer( funcAddr, typeof(DestroyFunc)) as DestroyFunc; } funcAddr = libLoader.GetFuncAddr("Analysis_GetTimeSteps"); if (funcAddr != IntPtr.Zero) { GetTimeSteps = Marshal.GetDelegateForFunctionPointer( funcAddr, typeof(GetTimeStepsFunc)) as GetTimeStepsFunc; } funcAddr = libLoader.GetFuncAddr("Analysis_GetTimeStepAt"); if (funcAddr != IntPtr.Zero) { GetTimeStepAt = Marshal.GetDelegateForFunctionPointer( funcAddr, typeof(GetTimeStepAtFunc)) as GetTimeStepAtFunc; } funcAddr = libLoader.GetFuncAddr("Analysis_DestroyTimeSteps"); if (funcAddr != IntPtr.Zero) { DestroyTimeSteps = Marshal.GetDelegateForFunctionPointer( funcAddr, typeof(DestroyFunc)) as DestroyFunc; } funcAddr = libLoader.GetFuncAddr("Analysis_GetFuncData"); if (funcAddr != IntPtr.Zero) { GetFuncData = Marshal.GetDelegateForFunctionPointer( funcAddr, typeof(GetFuncDataFunc)) as GetFuncDataFunc; } funcAddr = libLoader.GetFuncAddr("Analysis_GetFuncDataAt"); if (funcAddr != IntPtr.Zero) { GetFuncDataAt = Marshal.GetDelegateForFunctionPointer( funcAddr, typeof(GetFuncDataAtFunc)) as GetFuncDataAtFunc; } funcAddr = libLoader.GetFuncAddr("Analysis_DestroyFuncData"); if (funcAddr != IntPtr.Zero) { DestroyFuncData = Marshal.GetDelegateForFunctionPointer( funcAddr, typeof(DestroyFunc)) as DestroyFunc; } } // initialize the detector (or do nothing if data is still missing) LoadDetectorAndAnomaliesVector(); }
public Pool(T sample, CreateFunc createFunc, DestroyFunc destroyFunc, int initialSize = 100) : this(sample, createFunc, destroyFunc, (obj) => { }, (obj) => { }, initialSize) { }