protected override void Dispose(bool explicitDispose) { if (explicitDispose) { _runControl?.Dispose(); _postingCts?.Dispose(); var postingQueueSpinLock = _postingQueueSpinLock; if (postingQueueSpinLock != null) { postingQueueSpinLock.Invoke(() => _postingQueue.Fluent().NullCond(x => x.ToList())) .Fluent().NullCond(postingQueueCopy => postingQueueCopy.DisposeMany()); postingQueueSpinLock.Invoke(() => _postingQueue.Fluent().NullCond(x => x.Clear())); } var subscriptionsSpinLock = _subscriptionsSpinLock; if (subscriptionsSpinLock != null) { subscriptionsSpinLock.Invoke(() => _subscriptionsList.Fluent().NullCond(x => x.ToList())) .Fluent().NullCond(subscriptionsListCopy => subscriptionsListCopy.Where(i => (i.State & LocalSubscriptionStates.PublisherOwnsSubscription) == LocalSubscriptionStates.PublisherOwnsSubscription).DisposeMany()); subscriptionsSpinLock.Invoke(() => _subscriptionsList.Fluent().NullCond(x => x.Clear())); subscriptionsSpinLock.Invoke(() => _subscriptionsDictionary.Fluent().NullCond(x => x.Clear())); } _postingWorkers.DisposeAndClearArray(); } _postingQueue = null; _postingQueueSpinLock = null; _postingWorkers = null; _runningSettings = null; _subscriptionsDictionary = null; _subscriptionsList = null; _subscriptionsSpinLock = null; _runControl = null; _postingCts = null; // base.Dispose(explicitDispose); }
static MetadataPathName() { __ComponentDelimiterAsString = new string(ComponentDelimiter, 1); Regex = new Regex(pattern: RegexPattern, options: RegexOptions.Compiled); __CacheSpinLock = new PrimitiveSpinLock(); __Cache = new Dictionary <string, MetadataPathName>(StringComparer.Ordinal); }
protected override void Dispose(bool explicitDispose) { if (explicitDispose) { _newDependencyInstancesDisposeRegistry?.Dispose(); // _runningResolutionsSpinLock?.EnterAndExitLock(); _runningResolutionsUniqueness?.Clear(); _runningResolutionsSequence?.Clear(); // _resolutionModelLazy?.Dispose(); // _exporter?.Dispose(); // _outerScopeGetter?.Dispose(); } _newDependencyInstancesDisposeRegistry = null; _runningResolutionsUniqueness = null; _runningResolutionsSequence = null; _runningResolutionsSpinLock = null; _resolutionModelLazy = null; _exporter = null; _outerScopeGetter = null; _serviceProviderApi = null; _owner = null; // base.Dispose(explicitDispose); }
static DependencyScope() { DefaultOfMaxCountOfRunningResolutions = Math.Min(Math.Max(24, Environment.ProcessorCount), 48); DefaultOfMaxCountOfResolutionRedirect = 16; __ResolveDependencyInvokeRepoSpinLock = new PrimitiveSpinLock(); __ResolveDependencyInvokers = new Dictionary <Type, P_ResolveDependencyInvokerBase>(); }
public DisposeRegistry(int cleanupThreshold = default) { cleanupThreshold.Arg(nameof(cleanupThreshold)).EnsureNotLessThanZero(); // _disposablesSpinLock = new PrimitiveSpinLock(); _disposableWeakReferences = new List <StrictedWeakReference>(); _cleanupThreshold = cleanupThreshold == default ? __DefaultCleanupThreshold : cleanupThreshold; }
public TaskWrap(Task <TResult> task) { task.EnsureNotNull(nameof(task)); // _innerTask = task; _convertedTasks = new Dictionary <Type, Task>(capacity: 4); _convertedTasksSpinLock = new PrimitiveSpinLock(name: $"{nameof(TaskWrap<TResult>)}[{__ResultType.FullName}]"); }
protected MetadataTreeStructureContainerBase(TOwner ownerComponent) { ownerComponent.EnsureNotNull(nameof(ownerComponent)); // _ownerComponent = ownerComponent; _innerListSpinLock = new PrimitiveSpinLock(); _innerList = new LinkedList <TComponent>(); }
public DisposeRegistry(IEnumerable <IDisposable> disposables, int cleanupThreshold = default) { cleanupThreshold.Arg(nameof(cleanupThreshold)).EnsureNotLessThanZero(); // _disposablesSpinLock = new PrimitiveSpinLock(); _disposableWeakReferences = new List <StrictedWeakReference>(collection: disposables.EmptyIfNull().SkipNull().Select(locItem => new StrictedWeakReference(target: locItem, trackResurrection: false))); _cleanupThreshold = cleanupThreshold == default ? __DefaultCleanupThreshold : cleanupThreshold; }
static DisposableImplementation() { #if DEBUG __Counters = new Dictionary <Type, P_Counters>(); __CountersSpinLock = new PrimitiveSpinLock(); #else __Counters = new P_Counters(); #endif }
internal LocalPostingQueueEntry(LocalPostingToken postingToken, IEnumerable <ILocalSubscription> postingSubscriptions) { postingToken.EnsureNotNull(nameof(postingToken)); var locPostingSubscriptions = postingSubscriptions.EnsureNotNull(nameof(postingSubscriptions)).EnsureNoNullElements().Value.ToList(); // _postingToken = postingToken; _postingSubscriptions = locPostingSubscriptions; _postingSubscriptionsSpinLock = new PrimitiveSpinLock(); }
static XFullCorrelationId() { __ComponentDelimiterAsString = new string(c : ComponentDelimiter, count : 1); __CacheSpinLock = new PrimitiveSpinLock(); __Cache = new Dictionary <string, XFullCorrelationId>(StringComparer.Ordinal); __UseCache = false; RegexPattern = @"^(([\p{L}\p{Nd}_\-]{1,36}){1}(\.[\p{L}\p{Nd}_\-]{1,36}){0,127})$"; Regex = new Regex(pattern: RegexPattern, options: RegexOptions.Compiled); AppDomain = XCorrelationId.New(); }
protected override void Dispose(bool explicitDispose) { if (explicitDispose) { _strictedCtxsSpinLock?.EnterAndExitLock(); _strictedCtxs?.Values.Observe(action: locValue => locValue?.Dispose()); _strictedCtxs?.Clear(); } _strictedCtxs = null; _strictedCtxsSpinLock = null; // base.Dispose(explicitDispose); }
protected override void Dispose(bool explicitDispose) { if (explicitDispose) { _exportersSpinLock?.EnterAndExitLock(); _exporters?.Observe(i => i.Value.Dispose()); _exporters?.Clear(); } _exporters = null; _exportersSpinLock = null; // base.Dispose(explicitDispose); }
public DependencyResolutionContext(IDependencyScope scope, IDependencyResolutionSpecs specs, bool ownsSpecs = default, bool?isAdvancedLoggingEnabled = default) { scope.EnsureNotNull(nameof(scope)); specs.EnsureNotNull(nameof(specs)); // _sequentialId = DependencyUtilities.NextResolutionContextSequentialId(); _scope = scope; _specs = specs.ToValueHolder(ownsValue: ownsSpecs); _involvedHandlerCounters = new Dictionary <IDependencyHandler2, int>(comparer: ReferenceEqualityComparer <IDependencyHandler2> .Instance); _involvedHandlerChain = new List <IDependencyHandler2>(); _involvedHandlerSpinLock = new PrimitiveSpinLock(); // var resolutionSettings = DependencyUtilities.DefaultResolutionSettings; _usageCountLimitPerHandler = resolutionSettings.UsageCountLimitPerHandler; _isAdvancedLoggingEnabled = isAdvancedLoggingEnabled ?? resolutionSettings.IsAdvancedLoggingEnabled; }
protected override void Dispose(bool explicitDispose) { if (explicitDispose) { _specs?.Dispose(); _involvedHandlerSpinLock?.EnterAndExitLock(); _involvedHandlerChain?.Clear(); _involvedHandlerCounters?.Clear(); } _involvedHandlerCounters = null; _involvedHandlerChain = null; _involvedHandlerSpinLock = null; _scope = null; _specs = null; // base.Dispose(explicitDispose); }
internal LocalPostingWorker( Queue <LocalPostingQueueEntry> queue, PrimitiveSpinLock queueSpinLock, CancellationToken cancellationToken) { // queue.EnsureNotNull(nameof(queue)); queueSpinLock.EnsureNotNull(nameof(queueSpinLock)); cancellationToken.EnsureNotEmpty(nameof(cancellationToken)); // _queue = queue; _queueSpinLock = queueSpinLock; _cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); _breakLoopIdleEvent = new AutoResetEvent(initialState: false); _isLoopIdling = 0; _isLoopAlive = 0; _runControl = new RunControl <LocalPostingWorker>(options: RunControlOptions.SingleStart, component: this, start: P_DoStartAsync, stop: P_DoStopAsync); }
public LocalPublisher(ILocalPublisherSettings settings) { settings.EnsureNotNull(nameof(settings)).EnsureReadOnly().EnsureValid().EnsureNotDisabled(); // _runningSettings = settings; _subscriptionsSpinLock = new PrimitiveSpinLock(); _subscriptionsList = new List <ILocalSubscription>(); _subscriptionsDictionary = new Dictionary <ILocalSubscription, P_NewSubscriptionRegistrationState>(); _postingQueue = new Queue <LocalPostingQueueEntry>(); _postingQueueSpinLock = new PrimitiveSpinLock(); _postingCts = new CancellationTokenSource(); _postingWorkers = EnumerableUtilities .CreateSequence( factory: locIndex => new LocalPostingWorker(queue: _postingQueue, queueSpinLock: _postingQueueSpinLock, cancellationToken: _postingCts.Token), length: _runningSettings.PostingDop) .ToArray(); _runControl = new RunControl <LocalPublisher>(options: RunControlOptions.SingleStart, component: this, start: P_DoStartAsync, stop: P_DoStopAsync); }
void P_CtorInitializer(IDependencyExporter exporter, bool ownsDependencyExporter = default, IServiceProvider outerServiceProvider = default, object owner = default) { exporter.EnsureNotNull(nameof(exporter)); // _exporter = exporter.ToValueHolder(ownsDependencyExporter); _owner = owner; // _resolutionModelLazy = new DisposableLazy <IDependencyResolutionModel <DependencyScope> >( factory: () => new DependencyResolutionModel <DependencyScope>(scope: this, handlerChainSource: ReadDA(ref _exporter, considerDisposeRequest: true).Value.ExportDependencies()), ownsValue: true); // _newDependencyInstancesDisposeRegistry = new DisposeRegistry(); // _runningResolutionsSpinLock = new PrimitiveSpinLock(); _runningResolutionsUniqueness = new HashSet <IDependencyResolutionContext>(comparer: ReferenceEqualityComparer <IDependencyResolutionContext> .Instance); _runningResolutionsSequence = new List <IDependencyResolutionContext>(); // _serviceProviderApi = outerServiceProvider ?? new P_ServiceProviderApi(scope: this); }
protected override void Dispose(bool explicitDispose) { if (explicitDispose) { _innerListSpinLock?.EnterAndExitLock(); // var innerList = _innerList; if (innerList != null) { var innerListNode = innerList.First; for (; innerListNode != null;) { innerListNode.Value?.Dispose(); innerListNode = innerListNode.Next; } } _innerList?.Clear(); } _innerList = null; _innerListSpinLock = null; _ownerComponent = null; // base.Dispose(explicitDispose); }
public GarbageCollectionTracking() { _referencesRepo = new ConditionalWeakTable <TInstance, P_DestroyHnd>(); _referencesRepoSpinLock = new PrimitiveSpinLock(); _registeredCounter = 0L; }
static Leasable() { __CollectionRepo = new List <WeakReference <Leasable> >(); __CollectionRepoSpinLock = new PrimitiveSpinLock(); }
public DefaultDescriptionPackageService() { _loadedPackagesSpinLock = new PrimitiveSpinLock(); _loadedPackages = new Dictionary <DescriptionPackageLocator, P_LoadedPackageState>(comparer: DescriptionPackageLocator.PackageNameEqualityComparer); }
static ValueHolderUtilities() { __VhFactoriesSpinLock = new PrimitiveSpinLock(); __VhFactories = new Dictionary <Type, Delegate>(); }
static DisposableLazy() { __ValueCreationCallCounters = new Dictionary <object, P_ValueCreationCallCounterState>(comparer: ReferenceEqualityComparer <object> .Instance); __ValueCreationCallCountersSpinLock = new PrimitiveSpinLock(); }
public static TValue GetOrDefault <TKey, TValue>(this IDictionary <TKey, TValue> dictionary, PrimitiveSpinLock spinLock, TKey key) { dictionary.EnsureNotNull(nameof(dictionary)); spinLock.EnsureNotNull(nameof(spinLock)); // var value = default(TValue); return(spinLock.Invoke(() => dictionary.TryGetValue(key, out value)) ? value : default);
static NewInstanceDependencyTarget() { __DefaultHandlersSpinLock = new PrimitiveSpinLock(); __DefaultHandlers = new Dictionary <TypeTubple6, DisposableLazy <IFactoryDependencyHandler> >(); }
static EnumUtilities() { __EnumTypeApiCache = new Dictionary <Type, P_EnumTypeApi>(); __EnumTypeApiCacheSpinLock = new PrimitiveSpinLock(); }
public MetadataDependencyExporterBuilder() { _exporters = new Dictionary <IMetadata, P_MetadataDependencyExporter>(); _exportersSpinLock = new PrimitiveSpinLock(); }
public CompiledLambdaExpressionCache() { _spinLock = new PrimitiveSpinLock(); _methodCallCacheEntries = new Dictionary <MethodInfo, P_CacheEntryBase>(); }
static ResourceUtilities() { __StringResourcesRepoSpinLock = new PrimitiveSpinLock(); __StringResourcesRepo = new Dictionary <StringResourcesRepoKey, DisposableLazy <string> >(); }