Ejemplo n.º 1
0
 public void Using(Block block)
 {
     foreach (var runnable in block.Runnables)
     {
         Runnables.Add(runnable);
     }
     foreach (var value in block.Values)
     {
         if (Values.Find(o => o.Name == value.Name) != null)
         {
             continue;
         }
         Values.Add(value);
     }
     foreach (var func in block.Functions)
     {
         if (Values.Find(o => o.Name == func.Name) != null)
         {
             continue;
         }
         var clone = func.Clone() as Function;
         clone.Parent = this;
         Functions.Add(clone);
     }
 }
Ejemplo n.º 2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Path != null ? Path.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Runnables != null ? Runnables.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)ServerState;
         hashCode = (hashCode * 397) ^ (int)WorkspaceState;
         return(hashCode);
     }
 }
Ejemplo n.º 3
0
 public bool Equals(WorkspaceInfo other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(string.Equals(Path, other.Path) && Runnables.SequenceEqual(other.Runnables) && ServerState == other.ServerState && WorkspaceState == other.WorkspaceState);
 }
Ejemplo n.º 4
0
        public override void OnEntered()
        {
            Function = GetParentBlock().FindFunction(Name);

            if (Function == null)
            {
                Log.Error("メソッドの呼び出しに失敗しました: {0}->{1}", GetParentClass().FullName, Name);
                return;
            }
            Runnables.Add(Function);
            SetCaller();
            SetArgs();
        }
Ejemplo n.º 5
0
 public Runnable(Runnable other)
 {
     Source       = other.Source;
     ExecuteCount = other.ExecuteCount;
     foreach (var obj in other.Runnables)
     {
         var clone = (obj as Runnable).Clone();
         clone.Parent = this;
         Runnables.Add(clone);
     }
     Parent     = other.Parent;
     _isEntered = other._isEntered;
 }
Ejemplo n.º 6
0
        public override void OnEntered()
        {
            var methodName = ExtractMethodName(Source);

            if (methodName == "system_call")
            {
                Runnables.Add(new SystemCaller(this, Source));
            }
            else if (IsSetter(Source))
            {
                Runnables.Add(new ValueSetter(this, Source));
            }
            else
            {
                Runnables.Add(new Caller(this, Source));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Scans the store using store view and populates all participating <seealso cref="IndexPopulator"/> with data relevant to
        /// each index.
        /// The scan continues as long as there's at least one non-failed populator.
        /// </summary>
        public override void Run()
        {
            string oldThreadName = currentThread().Name;

            try
            {
                if (!_multiPopulator.hasPopulators())
                {
                    return;
                }
                if (_storeScan != null)
                {
                    throw new System.InvalidOperationException("Population already started.");
                }

                currentThread().Name = "Index populator";
                try
                {
                    _multiPopulator.create();
                    _multiPopulator.resetIndexCounts();

                    _monitor.indexPopulationScanStarting();
                    IndexAllEntities();
                    _monitor.indexPopulationScanComplete();
                    if (_cancelled)
                    {
                        _multiPopulator.cancel();
                        // We remain in POPULATING state
                        return;
                    }
                    _multiPopulator.flipAfterPopulation(_verifyBeforeFlipping);
                }
                catch (Exception t)
                {
                    _multiPopulator.fail(t);
                }
            }
            finally
            {
                // will only close "additional" resources, not the actual populators, since that's managed by flip
                Runnables.runAll("Failed to close resources in IndexPopulationJob", () => _multiPopulator.close(true), () => _monitor.populationJobCompleted(_memoryAllocationTracker.peakMemoryUsage()), _bufferFactory.close, _doneSignal.countDown, () => currentThread().setName(oldThreadName));
            }
        }
        private static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Please enter a task name as parameter, eg. \"lostmessages\"");
                return(-1);
            }

            var t = Runnables.GetRunnable(args[0]);

            if (t == null)
            {
                Console.WriteLine($"No task named \"{args[0]}\" found. Please give a valid task name, eg \"lostmessages\"");
                return(-1);
            }
            var runnable = Runnables.CreateRunnable(t, args.Skip(1));

            Console.WriteLine(runnable.Announcement);
            runnable.Run();
            return(0);
        }
Ejemplo n.º 9
0
 public override void OnLeaved()
 {
     Runnables.Clear();
 }
Ejemplo n.º 10
0
        public Block(Runnable parent, string text, string name = "") : base(parent, text)
        {
            if (name.Length > 0)
            {
                Name = name;
            }
            var sources = text.PoSplitSource();

            foreach (var source in sources)
            {
                if (source.PoMatchHead("func"))
                {
                    Functions.Add(new Function(this, source));
                }
                else if (source.PoMatchHead("test"))
                {
                    Tests.Add(new Function(this, source));
                }
                else if (source.PoMatchHead("class"))
                {
                    var def      = new Class(this, source);
                    var fullName = string.Format("{0}.{1}", FullName, def.Name);
                    if (!Class.ExistsStaticClass(fullName))
                    {
                        Class.AddStaticClass(fullName, def);
                    }
                    else
                    {
                        Class.GetStaticClass(fullName).Using(def);
                    }
                }
                else if (source.PoMatchHead("extension"))
                {
                    var def = new Class(this, source);
                    if (!Class.ExistsStaticExtension(def.Name))
                    {
                        Class.AddStaticExtension(def);
                    }
                    else
                    {
                        Class.GetStaticExtension(def.Name).Using(def);
                    }
                }
                else if (source.PoMatchHead("if") ||
                         source.PoMatchHead("else if") ||
                         source.PoMatchHead("else"))
                {
                    Runnables.Add(new If(this, source));
                }
                else if (source.PoMatchHead("count"))
                {
                    Runnables.Add(new Count(this, source));
                }
                else if (source.PoMatchHead("while"))
                {
                    Runnables.Add(new While(this, source));
                }
                else if (source.PoMatchHead("foreach"))
                {
                    Runnables.Add(new Foreach(this, source));
                }
                else if (source.PoMatchHead("for"))
                {
                    Runnables.Add(new For(this, source));
                }
                else if (source.PoMatchHead("return"))
                {
                    Runnables.Add(new Return(this, source));
                }
                else if (source.PoMatchHead("continue"))
                {
                    Runnables.Add(new Continue(this, source));
                }
                else if (source.PoMatchHead("break"))
                {
                    Runnables.Add(new Break(this, source));
                }
                else if (source.PoMatchHead("{"))
                {
                    Runnables.Add(new Block(this, source.PoExtract('{', '}')));
                }
                else
                {
                    Runnables.Add(new Term(this, source));
                }
            }
        }