private void ContextDisposing(SharedSynchronizationContextImpl context) { lock (_bag) { _bag.Remove(context); } }
public Registration(ThreadRunner sourceRunner, SharedSynchronizationContextImpl targetContext) { Console.WriteLine($"- Registration on {targetContext.Name}"); _sourceRunner = sourceRunner; _targetContext = targetContext; _nativeQueue = sourceRunner.TasksSource; _targetContext.RegisterExternalRunner(_sourceRunner); }
public SynchronizationContext GetSynchronizationContext(int startingCpu, int threadsCount, string name = null, CancellationToken token = default) { var context = new SharedSynchronizationContextImpl( this, startingCpu, threadsCount, name, CancellationTokenSource.CreateLinkedTokenSource(_cts.Token, token).Token); lock (_bag) { _bag.Add(context); } return(context); }
public ThreadRunner( SharedSynchronizationContextImpl host, int processorId, ManualResetEvent hasJobEvent, ConcurrentQueue <LocalTask> tasksSource, CancellationToken token) { _hasJobEvent = hasJobEvent; _host = host; _processorId = processorId; _cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token); TasksSource = tasksSource; _thread = new Thread(Start); _thread.Start(); }