Exemple #1
0
        internal void BlockOnInstructionWaitHandle(IBlockingInstruction instr)
        {
            // Runtime code
            instr.WaitHandle.WaitOne();

            /* Chess wrapper code
             * do
             * {
             *  SyncVarAccess;
             *  if (!instr.IsCompleted)
             *      LocalBacktrack();
             * }while(true);
             */
        }
Exemple #2
0
        /// <summary>
        /// Blocks the process and notifies the runtime that the state has changed just before blocking.
        /// </summary>
        internal void BlockProcessOnInstruction(MpiProcess p, IBlockingInstruction instr)
        {
            Debug.Assert(instr != null);

            // Setup state and notify the runtime we've changed the state of the runtime
            p.BlockingInstruction = instr;
            Interlocked.Increment(ref _blockedProcessesCount);
            _runtimeStateChangedEvent.Set();

            // And block
            BlockOnInstructionWaitHandle(instr);

            // Finished blocking, cleanup state
            Interlocked.Decrement(ref _blockedProcessesCount);
            p.BlockingInstruction = null;
        }
 /// <summary>
 /// Blocks the process and notifies the runtime that the state has changed just before blocking.
 /// </summary>
 protected void BlockProcessOnInstruction(IBlockingInstruction instr)
 {
     Runtime.BlockProcessOnInstruction(Process, instr);
 }