Beispiel #1
0
        private ActionBlock pushAdvice(string question, NodeReference correctAnswer)
        {
            var pushAction = createPushAction(question, correctAnswer);

            if (pushAction == null)
            {
                //we don't have more evidence - we just have to push given answer
                var block = new ActionBlock(Pool.Graph, new InsertAction(correctAnswer));
                return(block);
            }

            var pushedNodes = getFowardTargets(pushAction.SemanticOrigin);

            var relevantUtterances = lastRelevantUtterances(question, correctAnswer);
            var orderedUtterances  = (from utterance in relevantUtterances orderby getFowardTargets(utterance).Count select utterance).ToArray();
            var constraints        = new List <ConstraintAction>();

            for (var i = 0; i < orderedUtterances.Length - 1; ++i)
            {
                var constraintUtterance = orderedUtterances[i];

                var selectors = getBackwardTargets(constraintUtterance, pushedNodes);
                //var path = getCommonPath(selectors);

                var action = new ConstraintAction(constraintUtterance, constraintUtterance.Paths.First());
                constraints.Add(action);
            }

            var actions = new List <IPoolAction>();

            actions.Add(pushAction);
            actions.AddRange(constraints);

            return(new ActionBlock(Pool.Graph, actions));
        }
 // constructors for class attributes...
 public ForeignKeyAttribute(string name, Type referencedType, ConstraintAction onUpdate, ConstraintAction onDelete)
 {
     this.name = name;
     this.referencedType = referencedType;
     this.onUpdate = onUpdate;
     this.onDelete = onDelete;
 }
Beispiel #3
0
        /// <summary>
        /// Eine do - while schleife wird parallel auf mehreren Kernen ausgeführt.
        /// </summary>
        /// <typeparam name="T1">Type des ersten value Elements</typeparam>
        /// <typeparam name="T2">Type des zweiten value Elements</typeparam>
        /// <param name="constraint">Die bedingung für while.</param>
        /// <param name="constraintAction">Die änderung der while methode</param>
        /// <param name="action">Der Schleifenkörper der ausgeführt wird.
        /// (mit dem übergebenen Wert kann auf die Schleifenvariable zugegriffen werden)</param>
        /// <param name="value1">erstes value Element dass an den Schleifenkörper mitgegeben wird.</param>
        /// <param name="value2">zweites value Element dass an den Schleifenkörper mitgegeben wird.</param>
        public static void Do <T1, T2>(Constraint <int> constraint, ConstraintAction constraintAction,
                                       Action <T1, T2> action, T1 value1, T2 value2)
        {
            Do doExecution = new Do();

            doExecution.DoExecution <T1, T2>(constraint, constraintAction, action, value1, value2);
        }
Beispiel #4
0
        public void DoExecution <T1, T2>(Constraint <int> constraint, ConstraintAction constraintAction, Action <T1, T2> action, T1 value1, T2 value2)
        {
            int counter = 0;

            do
            {
                constraintAction.Invoke(ref counter);
            } while (constraint.Invoke(counter));
            chunk = counter / processorCount;
            int start = 0;
            int end   = chunk;

            for (int i = 1; i <= processorCount; i++)
            {
                int x = i - 1;
                waitHandles[x] = new ManualResetEvent(false);
                DoPart <T1, T2> doPart = new DoPart <T1, T2>();
                doPart.ExecutionPart = action;
                doPart.Constraint    = constraint;
                doPart.Start         = start;
                doPart.End           = end;
                doPart.Value1        = value1;
                doPart.Value2        = value2;
                DoSynchronisationContainer <T1, T2> doSynchronisationContainer =
                    new DoSynchronisationContainer <T1, T2>((ManualResetEvent)waitHandles[x], doPart);
                ThreadPool.QueueUserWorkItem(
                    delegate(object state)
                {
                    DoSynchronisationContainer <T1, T2> doSynchronisationContainerLocal = (DoSynchronisationContainer <T1, T2>)state;
                    DoPart <T1, T2> doPartLocal = doSynchronisationContainerLocal.DoPart_;
                    try
                    {
                        int intCounter = doPartLocal.Start;
                        do
                        {
                            doPartLocal.ExecutionPart.Invoke(ref intCounter, doPartLocal.Value1, doPartLocal.Value2);
                        }while (doPartLocal.Constraint.Invoke(intCounter) && (intCounter <= doPartLocal.End && intCounter >= doPartLocal.Start));
                    }
                    finally
                    {
                        doSynchronisationContainerLocal.ManualResetEvent_.Set();
                    }
                }
                    , doSynchronisationContainer);
                start = end + 1;
                end   = end + chunk;
            }
            WaitHandle.WaitAll(waitHandles);
        }
 public ForeignKeyAttribute(Type referencedType, ConstraintAction onUpdate, ConstraintAction onDelete)
     : this(null, referencedType, onUpdate, onDelete)
 {
 }
Beispiel #6
0
        /// <summary>
        /// Eine do - while schleife wird parallel auf mehreren Kernen ausgeführt.
        /// </summary>
        /// <typeparam name="T">Type des value Elements.</typeparam>
        /// <param name="constraint">Die bedingung für while.</param>
        /// <param name="constraintAction">Die änderung der while methode</param>
        /// <param name="action">Der Schleifenkörper der ausgeführt wird.
        /// (mit dem übergebenen Wert kann auf die Schleifenvariable zugegriffen werden)</param>
        /// <param name="value">value Element dass an den Schleifenkörper mitgegeben wird.</param>
        public static void Do <T>(Constraint <int> constraint, ConstraintAction constraintAction, Action <T> action, T value)
        {
            Do doExecution = new Do();

            doExecution.DoExecution <T>(constraint, constraintAction, action, value);
        }
Beispiel #7
0
        /// <summary>
        /// Eine do - while schleife wird parallel auf mehreren Kernen ausgeführt.
        /// </summary>
        /// <param name="constraint">Die bedingung für while.</param>
        /// <param name="constraintAction">Die änderung der while methode</param>
        /// <param name="action">Der Schleifenkörper der ausgeführt wird.
        /// (mit dem übergebenen Wert kann auf die Schleifenvariable zugegriffen werden)</param>
        public static void Do(Constraint <int> constraint, ConstraintAction constraintAction, Action action)
        {
            Do doExecution = new Do();

            doExecution.DoExecution(constraint, constraintAction, action);
        }