/// <summary> /// Construct a <see cref="WorkProcessor{T}"/>. /// </summary> /// <param name="ringBuffer">to which events are published.</param> /// <param name="barrier">on which it is waiting.</param> /// <param name="workHandler">is the delegate to which events are dispatched.</param> /// <param name="exceptionHandler">to be called back when an error occurs.</param> /// <param name="workSequence">from which to claim the next event to be worked on. It should always be initialised <see cref="Sequence.InitialValue"/></param> public WorkProcessor( RingBuffer <T> ringBuffer, ISequenceBarrier barrier, IWorkHandler <T> workHandler, IExceptionHandler <T> exceptionHandler, ISequence workSequence) { _ringBuffer = ringBuffer; _barrier = barrier; _workHandler = workHandler; _exceptionHandler = exceptionHandler; _workSequence = workSequence; _sequence = new Sequence(); if (_workHandler is ITimeoutHandler timeoutHandler) { _timeoutHandler = timeoutHandler; } if (_workHandler is ILifecycleAware lifecycleAware) { _lifecycleAware = lifecycleAware; } if (_workHandler is IEventReleaseAware eventReleaseAware) { _eventReleaser = new EventReleaser(_sequence); eventReleaseAware.SetEventReleaser(_eventReleaser); } }
public CacheManager(IEventAggregator eventAggregator, IWorkHandler workHandler, IDbContext dbContext) { _eventAggregator = eventAggregator; _workHandler = workHandler; _dbContext = dbContext; PopulateItems(); _timer = new Timer(PersistCacheData, null, Timeout.Infinite, Timeout.Infinite); }
public MainViewModel(IWorkHandler workHandler, DataContext dbContext) { _workHandler = workHandler; _dbContext = dbContext; GetDataCommand = new DelegateCommand(ExecuteGetDataCommand); SaveDataCommand = new DelegateCommand(ExecuteSaveDataCommand); Posts = new ObservableCollection<PostViewModel>(); }
/// <summary> /// Construct a <see cref="WorkProcessor{T}"/>. /// </summary> /// <param name="ringBuffer">ringBuffer to which events are published.</param> /// <param name="sequenceBarrier">sequenceBarrier on which it is waiting.</param> /// <param name="workHandler">workHandler is the delegate to which events are dispatched.</param> /// <param name="exceptionHandler">exceptionHandler to be called back when an error occurs</param> /// <param name="workSequence">workSequence from which to claim the next event to be worked on. It should always be initialised /// as <see cref="Sequencer.InitialCursorValue"/></param> public WorkProcessor(RingBuffer <T> ringBuffer, ISequenceBarrier sequenceBarrier, IWorkHandler <T> workHandler, IExceptionHandler exceptionHandler, Sequence workSequence) { _ringBuffer = ringBuffer; _sequenceBarrier = sequenceBarrier; _workHandler = workHandler; _exceptionHandler = exceptionHandler; _workSequence = workSequence; }
public NotificationService(IEventAggregator eventAggregator, IStatisticsViewModel statistics, IUserSettingsProvider userSettings, IWorkHandler workHandler) { _eventAggregator = eventAggregator; _statistics = statistics; _userSettings = userSettings; _workHandler = workHandler; eventAggregator.GetEvent<ShellInitializedEvent>().Subscribe(OnShellInitialized); }
public AutoUpdateDialog(IWorkHandler workHandler, IWindowManager windowManager, IStatisticsViewModel statistics) { _workHandler = workHandler; _windowManager = windowManager; _statistics = statistics; Owner = Application.Current.MainWindow; InitializeComponent(); Loaded += OnLoaded; }
public NotificationService(IEventAggregator eventAggregator, IStatisticsViewModel statistics, IUserSettingsProvider userSettings, IWorkHandler workHandler) { _eventAggregator = eventAggregator; _statistics = statistics; _userSettings = userSettings; _workHandler = workHandler; eventAggregator.GetEvent <ShellInitializedEvent>().Subscribe(OnShellInitialized); }
/// <summary> /// Construct a <see cref="WorkProcessor{T}"/>. /// </summary> /// <param name="ringBuffer">ringBuffer to which events are published.</param> /// <param name="sequenceBarrier">sequenceBarrier on which it is waiting.</param> /// <param name="workHandler">workHandler is the delegate to which events are dispatched.</param> /// <param name="exceptionHandler">exceptionHandler to be called back when an error occurs</param> /// <param name="workSequence">workSequence from which to claim the next event to be worked on. It should always be initialised /// as <see cref="Disruptor.Sequence.InitialCursorValue"/></param> public WorkProcessor(RingBuffer <T> ringBuffer, ISequenceBarrier sequenceBarrier, IWorkHandler <T> workHandler, IExceptionHandler <T> exceptionHandler, ISequence workSequence) { _ringBuffer = ringBuffer; _sequenceBarrier = sequenceBarrier; _workHandler = workHandler; _exceptionHandler = exceptionHandler; _workSequence = workSequence; _eventReleaser = new EventReleaser(this); (_workHandler as IEventReleaseAware)?.SetEventReleaser(_eventReleaser); _timeoutHandler = _workHandler as ITimeoutHandler; }
public UserStatisticsParticipationDialog(IWorkHandler workHandler) { _workHandler = workHandler; Owner = Application.Current.MainWindow; InitializeComponent(); if (!UserSettings.DisableUserStatisticsParticipation.HasValue) return; if (UserSettings.DisableUserStatisticsParticipation == true) { No.IsChecked = true; } else if (UserSettings.DisableUserStatisticsParticipation == false) { Yes.IsChecked = true; } }
public ISimplePipeline CreatePipeline() { _disruptor = new Disruptor <StepPayload>(() => new StepPayload(), 1024, TaskScheduler.Default /*, ProducerType.Multi, new BlockingSpinWaitWaitStrategy()*/); var handlerGroup = _disruptor.HandleEventsWithWorkerPool(_steps.First()); for (int i = 1; i < _steps.Count; i++) { var step = _steps[i]; var makeStepToArray = new IWorkHandler <StepPayload>[] { step }; handlerGroup = handlerGroup.HandleEventsWithWorkerPool(makeStepToArray); } _disruptor.Start(); return(this); }
public UserStatisticsParticipationDialog(IWorkHandler workHandler, IWindowManager windowManager, IStatisticsViewModel statisticsViewModel) { _workHandler = workHandler; Owner = Application.Current.MainWindow; InitializeComponent(); if (!UserSettings.DisableUserStatisticsParticipation.HasValue) { return; } if (UserSettings.DisableUserStatisticsParticipation == true) { No.IsChecked = true; } else if (UserSettings.DisableUserStatisticsParticipation == false) { Yes.IsChecked = true; } }
/// <summary> /// Construct a <see cref="WorkProcessor"/> /// </summary> /// <param name="ringBuffer">to which events are published.</param> /// <param name="sequenceBarrier">on which it is waiting</param> /// <param name="workHandler">is the delegate to which events are dispatched.</param> /// <param name="exceptionHandler">to be called back when an error occurs</param> /// <param name="workSequence">from which to claim the next event to be worked on. It should always be initialised as <see cref="Sequencer.INITIAL_CURSOR_VALUE"/></param> public WorkProcessor(RingBuffer <T> ringBuffer, ISequenceBarrier sequenceBarrier, IWorkHandler <T> workHandler, IExceptionHandler exceptionHandler, Sequence workSequence) { this.ringBuffer = ringBuffer; this.sequenceBarrier = sequenceBarrier; this.workHandler = workHandler; this.exceptionHandler = exceptionHandler; this.workSequence = workSequence; this.eventReleaser = new EventReleaser(this.sequence); if (this.workHandler is IEventReleaseAware) { (this.workHandler as IEventReleaseAware).SetEventReleaser(eventReleaser); } }
public FileManagerWindow(IUnityContainer container, IEventAggregator eventAggregator, IWorkHandler workHandler) { _container = container; _eventAggregator = eventAggregator; _workHandler = workHandler; Title = String.Format("GODspeed v{0}", App.ApplicationVersion); InitializeComponent(); CommandBindings.Add(new CommandBinding(FileManagerCommands.OpenDriveDropdownCommand, ExecuteOpenDriveDropdownCommand)); CommandBindings.Add(new CommandBinding(FileManagerCommands.SettingsCommand, ExecuteSettingsCommand)); CommandBindings.Add(new CommandBinding(FileManagerCommands.StatisticsCommand, ExecuteStatisticsCommand)); CommandBindings.Add(new CommandBinding(FileManagerCommands.AboutCommand, ExecuteAboutCommand)); CommandBindings.Add(new CommandBinding(FileManagerCommands.VisitWebsiteCommand, ExecuteVisitWebsiteCommand)); CommandBindings.Add(new CommandBinding(FileManagerCommands.UserStatisticsParticipationCommand, ExecuteUserStatisticsParticipationCommand)); CommandBindings.Add(new CommandBinding(FileManagerCommands.ExitCommand, ExecuteExitCommand)); CommandBindings.Add(new CommandBinding(FileManagerCommands.SplitterCommand, ExecuteSplitterCommand)); LayoutRoot.PreviewKeyDown += LayoutRootOnPreviewKeyDown; Closing += OnClosing; }
public OldCacheManager(IEventAggregator eventAggregator, IWorkHandler workHandler) { _eventAggregator = eventAggregator; _workHandler = workHandler; //Read cache to memory to fasten access _workHandler.Run(() => { //TODO: for cache migration //var dbFactory = new OrmLiteConnectionFactory(GetConnectionString(), SqliteDialect.Provider); //using (var db = dbFactory.Open()) //{ // db.CreateTableIfNotExists<CacheItem>(); // var sw = new Stopwatch(); // sw.Start(); // var keys = _cacheStore.Keys; // Debug.WriteLine("[DEBUG] {0} keys in cache", keys.Length); // foreach (var key in keys.Where(k => k.StartsWith(KeyPrefix))) // { // var v = Get(key); // var c = new CacheItem // { // Id = key.SubstringAfter(KeyPrefix), // Date = v.Date, // Expiration = v.Expiration, // Size = v.Size, // Title = v.Content.Title, // Type = v.Content.Type, // TitleType = v.Content.TitleType, // ContentType = v.Content.ContentType, // Thumbnail = v.Content.Thumbnail, // Content = // string.IsNullOrEmpty(v.TempFilePath) // ? null // : File.ReadAllBytes(v.TempFilePath) // }; // db.Insert(c); // } // sw.Stop(); // _cachePopupated = true; // Debug.WriteLine("Cache fetched [{0}]", sw.Elapsed); //} //return _inMemoryCache; var sw = new Stopwatch(); sw.Start(); var keys = _cacheStore.Keys; Debug.WriteLine("[DEBUG] {0} keys in cache", keys.Length); foreach (var key in keys.Where(k => k.StartsWith(KeyPrefix))) { Get(key); } sw.Stop(); _cachePopupated = true; Debug.WriteLine("Cache fetched [{0}]", sw.Elapsed); return _inMemoryCache; }, b => _eventAggregator.GetEvent<CachePopulatedEvent>().Publish(new CachePopulatedEventArgs(b, _cacheStore))); }
public OldCacheManager(IEventAggregator eventAggregator, IWorkHandler workHandler) { _eventAggregator = eventAggregator; _workHandler = workHandler; //Read cache to memory to fasten access _workHandler.Run(() => { //TODO: for cache migration //var dbFactory = new OrmLiteConnectionFactory(GetConnectionString(), SqliteDialect.Provider); //using (var db = dbFactory.Open()) //{ // db.CreateTableIfNotExists<CacheItem>(); // var sw = new Stopwatch(); // sw.Start(); // var keys = _cacheStore.Keys; // Debug.WriteLine("[DEBUG] {0} keys in cache", keys.Length); // foreach (var key in keys.Where(k => k.StartsWith(KeyPrefix))) // { // var v = Get(key); // var c = new CacheItem // { // Id = key.SubstringAfter(KeyPrefix), // Date = v.Date, // Expiration = v.Expiration, // Size = v.Size, // Title = v.Content.Title, // Type = v.Content.Type, // TitleType = v.Content.TitleType, // ContentType = v.Content.ContentType, // Thumbnail = v.Content.Thumbnail, // Content = // string.IsNullOrEmpty(v.TempFilePath) // ? null // : File.ReadAllBytes(v.TempFilePath) // }; // db.Insert(c); // } // sw.Stop(); // _cachePopupated = true; // Debug.WriteLine("Cache fetched [{0}]", sw.Elapsed); //} //return _inMemoryCache; var sw = new Stopwatch(); sw.Start(); var keys = _cacheStore.Keys; Debug.WriteLine("[DEBUG] {0} keys in cache", keys.Length); foreach (var key in keys.Where(k => k.StartsWith(KeyPrefix))) { Get(key); } sw.Stop(); _cachePopupated = true; Debug.WriteLine("Cache fetched [{0}]", sw.Elapsed); return(_inMemoryCache); }, b => _eventAggregator.GetEvent <CachePopulatedEvent>().Publish(new CachePopulatedEventArgs(b, _cacheStore))); }