コード例 #1
0
 public object ExecuteFunction(string funcName, object[] args, bool immediate)
 {
     if (RTSUtil.isGoodName(funcName))
     {
         IRTSThread t = null;
         if (immediate)
         {
             t = mImmediateT;
         }
         else
         {
             int p = 0;
             for (int i = 1; i <= mThreads.Length; i++)
             {
                 p = i % mThreads.Length;
                 if (mThreads[p].isFinished())
                 {
                     t = mThreads[p];
                     break;
                 }
             }
         }
         if (t == null || !t.isFinished())
         {
             return(false);
         }
         IRTSFunction func = mEngine.getFunction(funcName, args == null ? 0 : args.Length);
         if (func == null)
         {
             return(false);
         }
         bool ret = t.loadRunner(func.createRunner(args));
         if (immediate)
         {
             while (!t.isFinished())
             {
                 t.run(mEngine);
             }
             return(t.getOutput());
         }
         else
         {
             mExecUpdate |= ret;
             return(ret);
         }
     }
     else
     {
         return(null);
     }
 }
コード例 #2
0
        private int FindFreeThread(int threadId)
        {
            int        p = threadId;
            IRTSThread t = null;

            if (threadId >= 0)
            {
                t = threadId < mThreads.Length ? mThreads[threadId] : null;
                p = threadId;
            }
            else
            {
                for (int i = 1; i <= mThreads.Length; i++)
                {
                    p = i % mThreads.Length;
                    if (mThreads[p].isFinished())
                    {
                        t = mThreads[p];
                        break;
                    }
                }
            }
            if (t == null || !t.isFinished())
            {
                return(-1);
            }
            else
            {
                return(p);
            }
        }