public void Launch(IActor asker, IndexRouter router) { CheckArg.Actor(router); var response = new Response(router, asker, this); Become(new Behavior <Response>(r => DoProcessQuery(r))); SendMessage(response); }
public void Parse(IndexRouter indexRouter, Func <string, DataFolder, IEnumerable <Field> > fieldProducer) { foreach (var s in DoParse(Source)) { foreach (var field in fieldProducer(s, this)) { indexRouter.AddField(field); } } }
public IEnumerable <Field> Launch(IndexRouter router) { CheckArg.Actor(router); ConcurrentQueue <Field> bc = new ConcurrentQueue <Field>(); var spin = new SpinWait(); var asker = new BaseActor(new Behavior <string, IEnumerable <Field> > ( (s, fs) => { foreach (var item in fs) { bc.Enqueue(item); } ReceivedMsg++; if (ReceivedMsg == 1) { Interlocked.Increment(ref streamStart); } if (ReceivedMsg >= TotalMsg) { Interlocked.Increment(ref streamEnd); } } )); var response = new Response(router, asker, this); Become(new Behavior <Response>(r => DoProcessQuery(r))); SendMessage(response); while (Interlocked.CompareExchange(ref streamStart, streamStart, 0) == 0) { spin.SpinOnce(); } do { while (bc.TryDequeue(out Field field)) { yield return(field); } ; spin.SpinOnce(); }while (Interlocked.CompareExchange(ref streamEnd, streamEnd, 0) == 0); }
public Response(IndexRouter router, IActor asker, IQuery query) { Router = router; Asker = asker; Query = query; }