Esempio n. 1
0
            public bool Fall(int level, Token token, Params param, TaskCreationOptions taskCreationOptions = TaskCreationOptions.None)
            {
                lock (this)
                {
                    WaitFall();

                    if (token != null)
                    {
                        if (token.Cancellation.IsCancellationRequested)
                        {
                            return(false);
                        }

                        token.CountdownEvent.AddCount(1);
                    }

                    bool        haveSink = false;
                    BranchCache cache    = null;
                    if (param.Sink)
                    {
                        if (Cache.OperationCount > 0)
                        {
                            if (param.IsTotal)
                            {
                                cache    = Cache;
                                Cache    = new BranchCache();
                                haveSink = true;
                            }
                            else //no matter IsOverall or IsPoint, we exclude all the operations for the path
                            {
                                IOperationCollection operationCollection = Cache.Exclude(param.Path);
                                if (operationCollection != null)
                                {
                                    cache    = new BranchCache(/*param.Path,*/ operationCollection);
                                    haveSink = true;
                                }
                            }
                        }
                    }

                    Tree.WorkingFallCount.Increment();
                    FallTask = Task.Factory.StartNew(DoFall, new Tuple <Branch, BranchCache, int, Token, Params>(this, cache, level - 1, token, param), taskCreationOptions);

                    return(haveSink);
                }
            }
Esempio n. 2
0
            public bool Fall(int level, Token token, Params param, TaskCreationOptions taskCreationOptions = TaskCreationOptions.None)
            {
                lock (this)
                {
                    WaitFall();

                    if (token != null)
                    {
                        if (token.Cancellation.IsCancellationRequested)
                            return false;

                        token.CountdownEvent.AddCount(1);
                    }

                    bool haveSink = false;
                    BranchCache cache = null;
                    if (param.Sink)
                    {
                        if (Cache.OperationCount > 0)
                        {
                            if (param.IsTotal)
                            {
                                cache = Cache;
                                Cache = new BranchCache();
                                haveSink = true;
                            }
                            else //no matter IsOverall or IsPoint, we exclude all the operations for the path
                            {
                                IOperationCollection operationCollection = Cache.Exclude(param.Path);
                                if (operationCollection != null)
                                {
                                    cache = new BranchCache(/*param.Path,*/ operationCollection);
                                    haveSink = true;
                                }
                            }
                        }
                    }

                    Tree.WorkingFallCount.Increment();
                    FallTask = Task.Factory.StartNew(DoFall, new Tuple<Branch, BranchCache, int, Token, Params>(this, cache, level - 1, token, param), taskCreationOptions);

                    return haveSink;
                }
            }