예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Mock{T}"/> class.
 /// </summary>
 internal Mock(ActorExecutionContext.Mock context, T value)
     : base(value)
 {
     this.Context       = context;
     this.RegisterActor = context.CreateActor(typeof(SharedRegisterActor <T>));
     context.SendEvent(this.RegisterActor, SharedRegisterEvent.SetEvent(value));
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Mock{T}"/> class.
 /// </summary>
 internal Mock(ControlledRuntime runtime, T value)
     : base(value)
 {
     this.Runtime       = runtime;
     this.RegisterActor = this.Runtime.CreateActor(typeof(SharedRegisterActor <T>));
     this.Runtime.SendEvent(this.RegisterActor, SharedRegisterEvent.SetEvent(value));
 }
예제 #3
0
            /// <summary>
            /// Gets current value of the register.
            /// </summary>
            public override T GetValue()
            {
                var op = this.Context.Runtime.GetExecutingOperation <ActorOperation>();

                this.Context.SendEvent(this.RegisterActor, SharedRegisterEvent.GetEvent(op.Actor.Id));
                var e = op.Actor.ReceiveEventAsync(typeof(SharedRegisterResponseEvent <T>)).Result as SharedRegisterResponseEvent <T>;

                return(e.Value);
            }
예제 #4
0
            /// <summary>
            /// Reads and updates the register.
            /// </summary>
            public override T Update(Func <T, T> func)
            {
                var op = this.Context.Scheduler.GetExecutingOperation <ActorOperation>();

                this.Context.SendEvent(this.RegisterActor, SharedRegisterEvent.UpdateEvent(func, op.Actor.Id));
                var e = op.Actor.ReceiveEventAsync(typeof(SharedRegisterResponseEvent <T>)).Result as SharedRegisterResponseEvent <T>;

                return(e.Value);
            }
예제 #5
0
 /// <summary>
 /// Sets current value of the register.
 /// </summary>
 public override void SetValue(T value)
 {
     this.Context.SendEvent(this.RegisterActor, SharedRegisterEvent.SetEvent(value));
 }