// needed tests: // 1. make sure a lot of tasks all get done // 2. make sure an exception on 1, 3, or 5 of 5 still lets the others run // 3. cancelling before it runs or during a run should return cancelled tasks // 4. make sure the four that should keep them in order do // 5. make sure each actor can handle multiple threads pushing to it private IEnumerable <IActor <T, R> > CreateActors <T, R>(SetFunc <T, R> func) { yield return(new OrderedSyncActor <T, R>(func)); yield return(new OrderedAsyncActor <T, R>(func)); yield return(new UnorderedAsyncActor <T, R>(func)); yield return(new PeriodicAsyncActor <T, R>(func, TimeSpan.FromMilliseconds(20))); yield return(new MostRecentAsyncActor <T, R>(func)); }
static _Set() { var dynamicMethod = new DynamicMethod ( "Set", typeof(void), new[] { typeof(IntPtr), typeof(byte), typeof(uint) }, typeof(_Set) ); var ilGenerator = dynamicMethod.GetILGenerator(); ilGenerator.Emit(OpCodes.Ldarg_0); ilGenerator.Emit(OpCodes.Ldarg_1); ilGenerator.Emit(OpCodes.Ldarg_2); ilGenerator.Emit(OpCodes.Initblk); ilGenerator.Emit(OpCodes.Ret); set = (SetFunc)dynamicMethod.CreateDelegate(typeof(SetFunc)); }
public IActor <T, R> Create <T, R>(ActorType type, SetFunc <T, R> action, TimeSpan?period = null) { switch (type) { case ActorType.MostRecentAsync: return(new MostRecentAsyncActor <T, R>(action)); case ActorType.OrderedAsync: return(new OrderedAsyncActor <T, R>(action)); case ActorType.OrderedSync: return(new OrderedSyncActor <T, R>(action)); case ActorType.PeriodicAsync: return(new PeriodicAsyncActor <T, R>(action, period.GetValueOrDefault(TimeSpan.FromSeconds(0.1)))); case ActorType.UnorderedAsync: return(new UnorderedAsyncActor <T, R>(action)); default: throw new NotSupportedException(); } }