/// <summary> /// Initializes a new instance of the <see cref="PastaPricingAgent"/> class. /// </summary> /// <param name="pastaSequencer"> /// The sequencer to use for this agent (sequencer: race condition killer). /// </param> /// <param name="pastaName"> /// Name of the pasta. /// </param> /// <param name="conflationEnabled">Set to true to activate conflation.</param> public PastaPricingAgent(ISequencer pastaSequencer, string pastaName, bool conflationEnabled = false) { this.pastaSequencer = pastaSequencer; if (conflationEnabled) { // Conflation with balking strategy this.eggUnitOfExecution = new BalkingDispatcher(this.pastaSequencer); this.flourUnitOfExecution = new BalkingDispatcher(this.pastaSequencer); this.flavorUnitOfExecution = new BalkingDispatcher(this.pastaSequencer); this.packagingUnitOfExecution = new BalkingDispatcher(this.pastaSequencer); this.sizeUnitOfExecution = new BalkingDispatcher(this.pastaSequencer); } else { // for testing purposes var exec = pastaSequencer; // All events processed this.eggUnitOfExecution = exec; this.flourUnitOfExecution = exec; this.flavorUnitOfExecution = exec; this.packagingUnitOfExecution = exec; this.sizeUnitOfExecution = exec; } this.PastaName = pastaName; }
// using a single thread unit of execution should lead to a sequential execution of Actions private ISequencer BuildSequencer(IUnitOfExecution synchExec) { var sequencer = this.Constructor.Invoke(new object[] { synchExec }) as ISequencer; Check.That(sequencer).IsNotNull(); return(sequencer); }
public PastaPricerEngine(IUnitOfExecution unitOfExecution, IEnumerable<string> pastasConfiguration, IMarketDataProvider marketDataProvider, IPastaPricerPublisher pastaPricerPublisher, bool conflationEnabled = false) { this.unitOfExecution = unitOfExecution; this.pastasConfiguration = pastasConfiguration; this.marketDataProvider = marketDataProvider; this.pastaPricerPublisher = pastaPricerPublisher; this.conflationEnabled = conflationEnabled; }
public PastaPricerEngine(IUnitOfExecution unitOfExecution, IEnumerable <string> pastasConfiguration, IMarketDataProvider marketDataProvider, IPastaPricerPublisher pastaPricerPublisher, bool conflationEnabled = false) { this.unitOfExecution = unitOfExecution; this.pastasConfiguration = pastasConfiguration; this.marketDataProvider = marketDataProvider; this.pastaPricerPublisher = pastaPricerPublisher; this.conflationEnabled = conflationEnabled; }
/// <summary> /// Creates <see cref="DataProcessor{T}"/> instance that will process incoming data asynchronously. /// </summary> /// <param name="executor"> /// An <see cref="IUnitOfExecution"/> instance that will ultimately execute the task. /// </param> /// <param name="action"> /// <see cref="Action{T}"/> instance that will process the data. /// </param> /// <param name="conflated">True if data can be conflated. </param> /// <typeparam name="T"> /// Type of data to be processed. /// </typeparam> /// <returns> /// The <see cref="Action"/>. /// </returns> public static IDataProcessor <T> BuildProcessor <T>(this IUnitOfExecution executor, Action <T> action, bool conflated) { if (conflated) { return(new DataConflator <T>(executor, action)); } else { return(new DataProcessor <T>(executor, action)); } }
/// <summary> /// Initializes a new instance of the <see cref="Middleware"/> class. /// </summary> /// <param name="asyncMode">if set to <c>true</c> middleware is async mode.</param> public Middleware(bool asyncMode = true) { if (asyncMode) { this.root = TestHelpers.GetPool(); } else { this.root = TestHelpers.GetSynchronousUnitOfExecution(); } this.sequencer = this.root.BuildSequencer(); }
/// <summary> /// Initializes a new instance of the <see cref="Middleware"/> class. /// </summary> /// <param name="asyncMode">if set to <c>true</c> middleware is async mode.</param> public Middleware(bool asyncMode = true) { if (asyncMode) { this.root = TestHelpers.GetPool(); } else { this.root = TestHelpers.GetSynchronousUnitOfExecution(); } this.sequencer = this.root.BuildSequencer(); }
public TaskContinuationSequencer(IUnitOfExecution executor) { this._scheduler = new TaskSchedulerAdapter(executor); }
/// <summary> /// Build a sequencer on top of an <see cref="ISequencer"/>. /// </summary> /// <param name="executor"> /// The executor that will be used to provide sequential execution. /// </param> /// <returns> /// The <see cref="ISequencer"/>. /// </returns> public static ISequencer BuildSequencer(this IUnitOfExecution executor) { return(executor.UnitOfExecutionsFactory.GetSequence(executor)); }
/// <summary> /// Initializes a new instance of the <see cref="BalkingDispatcher"/> class. /// </summary> /// <param name="rootDispatcher">The root dispatcher.</param> public BalkingDispatcher(IUnitOfExecution rootDispatcher) { this.rootDispatcher = rootDispatcher; }
/// <summary> /// Initializes a new instance of the <see cref="DataProcessor{T}"/> class. /// </summary> /// <param name="executor"> /// The executor. /// </param> /// <param name="action"> /// The action. /// </param> public DataProcessor(IUnitOfExecution executor, Action <T> action) { this.executor = executor; this.action = action; }
/// <summary> /// Initializes a new instance of the <see cref="ActionConflator"/> class. /// </summary> /// <param name="unitOfExecution"> /// The unit of execution. /// </param> public ActionConflator(IUnitOfExecution unitOfExecution) { this.unitOfExecution = unitOfExecution; }
/// <summary> /// Initializes a new instance of the <see cref="DataConflator{T}"/> class. /// </summary> /// <param name="unitOfExecution"> /// The unit of execution. /// </param> /// <param name="action"> /// The action. /// </param> public DataConflator(IUnitOfExecution unitOfExecution, Action <T> action) { this.unitOfExecution = unitOfExecution; this.action = action; }
/// <summary> /// Initializes a new instance of the <see cref="PastaPricingAgent"/> class. /// </summary> /// <param name="pastaSequencer"> /// The sequencer to use for this agent (sequencer: race condition killer). /// </param> /// <param name="pastaName"> /// Name of the pasta. /// </param> /// <param name="conflationEnabled"></param> public PastaPricingAgent(ISequencer pastaSequencer, string pastaName, bool conflationEnabled = false) { this.pastaSequencer = pastaSequencer; if (conflationEnabled) { // Conflation with balking strategy this.eggUnitOfExecution = new BalkingDispatcher(this.pastaSequencer); this.flourUnitOfExecution = new BalkingDispatcher(this.pastaSequencer); this.flavorUnitOfExecution = new BalkingDispatcher(this.pastaSequencer); } else { // All events processed this.eggUnitOfExecution = this.pastaSequencer; this.flourUnitOfExecution = this.pastaSequencer; this.flavorUnitOfExecution = this.pastaSequencer; } this.PastaName = pastaName; }
/// <summary> /// Initializes a new instance of the <see cref="Sequencer" /> class. /// </summary> /// <param name="rootUnitOfExecution">The root Dispatcher.</param> public Sequencer(IUnitOfExecution rootUnitOfExecution) { this.rootUnitOfExecution = rootUnitOfExecution; this.numberOfPendingTasksWhileRunning = 0; }
public TaskContinuationSequencer(IUnitOfExecution executor) { this._scheduler = new TaskSchedulerAdapter(executor); }
/// <summary> /// Initializes a new instance of the <see cref="Sequencer" /> class. /// </summary> /// <param name="rootUnitOfExecution">The root Dispatcher.</param> public Sequencer(IUnitOfExecution rootUnitOfExecution) { this.rootUnitOfExecution = rootUnitOfExecution; this.numberOfPendingTasksWhileRunning = 0; }
private readonly LinkedList<Task> _tasks = new LinkedList<Task>(); // protected by lock(_tasks) public TaskSchedulerAdapter(IUnitOfExecution executor) { this._executor = executor; }
/// <summary> /// Build a <see cref="ISequencer"/> wrapping an <see cref="IUnitOfExecution"/>. /// </summary> /// <param name="execution"><see cref="IUnitOfExecution"/> that will carry out sequenced task.</param> /// <returns>A <see cref="ISequencer"/> instance.</returns> public ISequencer GetSequence(IUnitOfExecution execution) { return(new Sequencer(execution)); }
/// <summary> /// Build a conflated version of an <see cref="Action"/> on top of an <see cref="ISequencer"/>. /// </summary> /// <typeparam name="T">Parameter type.</typeparam> /// <param name="executor">The execution unit that will be used to execute conflated <paramref name="action"/>.</param> /// <param name="action">Action to be executed in a conflated fashion.</param> /// <returns>A wrapped <see cref="Action"/> that provide conflated execution.</returns> public static Action <T> BuildConflator <T>(this IUnitOfExecution executor, Action <T> action) { var conflator = new DataConflator <T>(executor, action); return(conflator.Post); }
/// <summary> /// Initializes a new instance of the <see cref="BalkingDispatcher"/> class. /// </summary> /// <param name="rootDispatcher">The root dispatcher.</param> public BalkingDispatcher(IUnitOfExecution rootDispatcher) { this.rootDispatcher = rootDispatcher; }
private readonly LinkedList <Task> tasks = new LinkedList <Task>(); // protected by lock(_tasks) public TaskSchedulerAdapter(IUnitOfExecution executor) { this.executor = executor; }