Esempio n. 1
0
 public SelectServerHelper(Cluster cluster, IServerSelector selector)
 {
     _cluster = cluster;
     _selector = DecorateSelector(selector);
     _stopwatch = Stopwatch.StartNew();
     _timeoutAt = DateTime.UtcNow + _cluster.Settings.ServerSelectionTimeout;
 }
Esempio n. 2
0
 public  WaitForDescriptionChangedHelper(Cluster cluster, IServerSelector selector, ClusterDescription description, Task descriptionChangedTask , TimeSpan timeout, CancellationToken cancellationToken)
 {
     _cluster = cluster;
     _description = description;
     _selector = selector;
     _descriptionChangedTask = descriptionChangedTask;
     _cancellationToken = cancellationToken;
     _cancellationTaskCompletionSource = new TaskCompletionSource<bool>();
     _cancellationTokenRegistration = cancellationToken.Register(() => _cancellationTaskCompletionSource.TrySetCanceled());
     _timeoutCancellationTokenSource = new CancellationTokenSource();
     _timeoutTask = Task.Delay(timeout, _timeoutCancellationTokenSource.Token);
 }
 public static InterlockedInt32 _state(this Cluster cluster) => (InterlockedInt32)Reflector.GetFieldValue(cluster, nameof(_state));