Beispiel #1
0
        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);
        }
Beispiel #2
0
 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);
         }
     }
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 public Response(IndexRouter router, IActor asker, IQuery query)
 {
     Router = router;
     Asker  = asker;
     Query  = query;
 }