public OnePublisherToOneProcessorRawThroughputTest() : base(TestName, 1000L * 1000L * 100L) { sequencer = new SingleProducerSequencer(BUFFER_SIZE, new YieldingWaitStrategy()); myRunnable = new MyRunnable(sequencer); sequencer.AddGatingSequences(myRunnable.GetSequence); }
internal static string[] GetSequence(ISequencer sequencer, int number) { return sequencer.YieldSequence() .TakeWhile(x => x <= number) .Select(sequencer.MapInteger) .ToArray(); }
public void SetUp() { injectionBinder = new InjectionBinder(); injectionBinder.Bind<IInjectionBinder> ().Bind<IInstanceProvider> ().ToValue (injectionBinder); injectionBinder.Bind<ISequencer> ().Bind<ICommandBinder>().To<Sequencer> ().ToSingleton (); sequencer = injectionBinder.GetInstance<ISequencer> () as ISequencer; }
public void SetUp() { _sequencerMock = new Mock<ISequencer>(); _sequencer = _sequencerMock.Object; _sequencerMock.SetupGet(x => x.BufferSize).Returns(16); _ringBuffer = new RingBuffer<StubEvent>(StubEvent.EventFactory, _sequencer); }
public void Init() { var sequencerMock = new Mock<ISequencer>(); sequencerMock.Setup(s => s.YieldSequence()).Returns(() => returnSequence); mapItem = i => i.ToString(); sequencerMock.Setup(s => s.MapInteger(It.IsAny<int>())).Returns((int i) => mapItem(i)); sequencer = sequencerMock.Object; }
/// <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 ProcessingSequenceBarrier( ISequencer sequencer, IWaitStrategy waitStrategy, Sequence cursorSequence, Sequence[] dependentSequences) { this.sequencer = sequencer; this.waitStrategy = waitStrategy; this.cursorSequence = cursorSequence; if (dependentSequences.Length == 0) this.dependentSequence = cursorSequence; else this.dependentSequence = new FixedSequenceGroup(dependentSequences); }
public TrainingSession(IUserSettings settings, ITimer timer, ITrainer trainer, ITaunter taunter, IMetronome metronome, ISequencer sequencer, IContentCollection content, IContentViewer viewer, IRandomNumberGenerator randomNumberGenerator) { _taunter = taunter; Settings = settings; Trainer = trainer; Taunter = taunter; Metronome = metronome; Sequencer = sequencer; Content = content; Viewer = viewer; Timer = timer; RNG = randomNumberGenerator; }
private static void MeasureThroughput(ISequencer sequencer) { const int ActionsCount = 1000 * 1000; var stopSignal = new ManualResetEvent(false); var stopwatch = Stopwatch.StartNew(); for (var actionIndex = 0; actionIndex < ActionsCount; ++actionIndex) { sequencer.Dispatch(() => { }); } sequencer.Dispatch(() => stopSignal.Set()); stopSignal.WaitOne(); stopwatch.Stop(); Console.WriteLine("Sequencer: {0,-35}, Throughput: {1,10:N0} actions / sec", sequencer.GetType().Name, ActionsCount / stopwatch.Elapsed.TotalSeconds); }
public void MapItem_SequencersExceptFizzBuzz() { var sequencersWithDefaultMapping = new ISequencer[] { new AllSequencer(), new OddSequencer(), new EvenSequencer(), new FibonacciSequencer() }; foreach (var sequencer in sequencersWithDefaultMapping) { Enumerable.Range(1, 20) .Select(sequencer.MapInteger) .ShouldAllBeEquivalentTo(new[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20" }); } }
/// <summary> /// Construct a ValueRingBuffer with the full option set. /// </summary> /// <param name="sequencer">sequencer to handle the ordering of events moving through the ring buffer.</param> /// <exception cref="ArgumentException">if bufferSize is less than 1 or not a power of 2</exception> public ValueRingBuffer(ISequencer sequencer) : this(() => default(T), sequencer) { }
public PlayerMedkitEngine(ISequencer playerHealSequence, ISequencer playerPickupSequence) { _playerHealSequence = playerHealSequence; _playerPickupSequence = playerPickupSequence; }
public static long ComputeHighestPublishedSequence(this ISequencer sequencer) { return(sequencer.GetHighestPublishedSequence(0, sequencer.Cursor)); }
public BoardPressEngine(ISequencer boardPressSequence) { this.boardPressSequence = boardPressSequence; }
public static EventPoller <T> Create <T>(IDataProvider <T> dataProvider, ISequencer sequencer, Sequence sequence, Sequence cursorSequence, params ISequence[] gatingSequences) { var gatingSequence = SequenceGroups.CreateReadOnlySequence(cursorSequence, gatingSequences); return(new EventPoller <T>(dataProvider, sequencer, sequence, gatingSequence)); }
public NotificationRepository(IMySQLStream <Notification> stream, ISequencer <int> sequencer) : base(stream, sequencer) { }
/// <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; }
public EquipmentRepository(ICSVStream <Equipment> stream, ISequencer <long> sequencer) : base(stream, sequencer) { }
public TurnOrderEngine(ISequencer battleTurnSequence, UIService uiService) { _taskRoutine = TaskRunner.Instance.AllocateNewTaskRoutine().SetEnumerator(Tick()); _battleTurnSequence = battleTurnSequence; _uiService = uiService; }
//private IManagerRepository _managerRepository; //private ISecretaryRepository _secretaryRepository; public DoctorFeedbackRepository(ICSVStream <DoctorFeedback> stream, ISequencer <long> sequencer, IQuestionRepository questionRepository, IPatientRepository patientRepository, IDoctorRepository doctorRepository) : base(ENTITY_NAME, stream, sequencer, new LongIdGeneratorStrategy <DoctorFeedback>()) { _questionRepository = questionRepository; _patientRepository = patientRepository; _doctorRepository = doctorRepository; }
public UnitTurnActionEngine(ISequencer turnSequence) { _turnSequence = turnSequence; }
public static ValueEventPoller <T> Create <T>(IValueDataProvider <T> dataProvider, ISequencer sequencer, Sequence sequence, Sequence cursorSequence, params ISequence[] gatingSequences) where T : struct { var gatingSequence = SequenceGroups.CreateReadOnlySequence(cursorSequence, gatingSequences); return(new ValueEventPoller <T>(dataProvider, sequencer, sequence, gatingSequence)); }
public RenovationRepository(IMySQLStream <Renovation> stream, ISequencer <int> sequencer) : base(stream, sequencer) { }
public TowerModalAnswerEngine(ISequencer towerModalConfirmSequence) { this.towerModalConfirmSequence = towerModalConfirmSequence; }
public DrugRepository(ICSVStream <Drug> stream, ISequencer <long> sequencer, IIngredientRepository ingredientRepository) : base(stream, sequencer) { _ingredientRepository = ingredientRepository; }
public CSVGetterRepository(ICSVStream <E> stream, ISequencer <ID> sequencer) { _stream = stream; _sequencer = sequencer; InitializeId(); }
public DetermineMoveTypeEngine(ISequencer moveSequence) { this.moveSequence = moveSequence; }
public AnamnesisRepository( ICSVStream <Anamnesis> stream, ISequencer <long> sequencer ) : base(ENTITY_NAME, stream, sequencer) { }
public ForcedRearrangementAbilityEngine(ISequencer forcedRearrangementSequence) { this.forcedRearrangementSequence = forcedRearrangementSequence; }
public LocationRepository(IMySQLStream <Location> stream, ISequencer <long> sequencer) : base(ENTITY_NAME, stream, sequencer, new LongIdGeneratorStrategy <Location>()) { }
public BetrayalEngine(ISequencer betrayalSequence) { this.betrayalSequence = betrayalSequence; }
private bool Create(string configFile) { try { this.ClusterConfig = ClusterFactory.Instance.CreateCluster(configFile); this.EnvironmentMonitor = new EnvironmentMonitor(this.ClusterConfig); this.HardwareMonitor = new HardwareMonitor(this.ClusterConfig); this.TabletMagazine = new TabletMagazine(); this.OrderConsumer = new OrderConsumer(); this._sequencer = new FSMSequencer(this); this._eStopMonitor = new EmergencyStopMonitor(this); } catch (Exception ex) { var outer = new Exception("Unable to initialise the SCADA system", ex); Logger.Instance.Write(new LogEntry(outer, LogType.Error)); return false; } this.StartAllTimers(); return true; }
public FeedbackRepository( ICSVStream <Feedback> stream, ISequencer <long> sequencer ) : base(ENTITY_NAME, stream, sequencer) { }
public DropModalAnswerEngine(ISequencer dropModalAnswerSequence) { this.dropModalAnswerSequence = dropModalAnswerSequence; }
public static void AddTween(this ISequencer This, Func <Tween> action) { This.Add(() => action().ToCompletable()); }
public MySQLRepository(IMySQLStream <E> stream, ISequencer <ID> sequencer) { this.stream = stream; this.sequencer = sequencer; }
public MyRunnable(ISequencer sequencer) { _barrier = sequencer.NewBarrier(); }
/// <summary> /// Construct a RingBuffer with the full option set. /// </summary> /// <param name="eventFactory">eventFactory to create entries for filling the RingBuffer</param> /// <param name="sequencer">sequencer to handle the ordering of events moving through the RingBuffer.</param> /// <exception cref="ArgumentException">if bufferSize is less than 1 or not a power of 2</exception> public RingBuffer(Func <T> eventFactory, ISequencer sequencer) : base(sequencer, typeof(T), _bufferPadRef) { Fill(eventFactory); }
public void Setup() { this.sequencer = newProducer(producerType, BUFFER_SIZE, new BlockingWaitStrategy()); }
public InventoryItemRepository(IMySQLStream <InventoryItem> stream, ISequencer <long> sequencer) : base(ENTITY_NAME, stream, sequencer, new LongIdGeneratorStrategy <InventoryItem>()) { }
public _MyRunnable(ISequencer sequencer) { this.barrier = sequencer.NewBarrier(); }
public AllergiesRepository(IMySQLStream <Allergies> stream, ISequencer <int> sequencer) : base(stream, sequencer) { }
protected override void instantiateCoreComponents() { base.instantiateCoreComponents(); commandBinder = injectionBinder.GetInstance<ICommandBinder>() as ICommandBinder; dispatcher = injectionBinder.GetInstance<IEventDispatcher>(ContextKeys.CONTEXT_DISPATCHER) as IEventDispatcher; mediationBinder = injectionBinder.GetInstance<IMediationBinder>() as IMediationBinder; sequencer = injectionBinder.GetInstance<ISequencer>() as ISequencer; implicitBinder = injectionBinder.GetInstance<IImplicitBinder>() as IImplicitBinder; (dispatcher as ITriggerProvider).AddTriggerable(commandBinder as ITriggerable); (dispatcher as ITriggerProvider).AddTriggerable(sequencer as ITriggerable); }
public PatientRepository(ICSVStream <Patient> stream, ISequencer <UserID> sequencer, IEagerCSVRepository <Doctor, UserID> doctorRepository, IUserRepository userRepository) : base(ENTITY_NAME, stream, sequencer, new PatientIdGeneratorStrategy()) { _doctorRepository = doctorRepository; _userRepository = userRepository; }
public CaptureStackModalAnswerEngine(ISequencer captureStackModalAnswerSequence) { this.captureStackModalAnswerSequence = captureStackModalAnswerSequence; }