Example #1
0
            internal CMtThread(int index, CMtCoder mtCoder) // CMtThread_Construct
            {
                Trace.MatchObjectCreate(this, "CMtThread_Construct");

                mIndex   = index;
                mMtCoder = mtCoder;
                mOutBuf  = null;
                mInBuf   = null;

                Event_Construct(out mCanRead);
                Event_Construct(out mCanWrite);

                mThread = new CLoopThread();
            }
Example #2
0
            internal SRes MtCoder_Code()
            {
                int  numThreads = mNumThreads;
                SRes res        = SZ_OK;

                mRes = SZ_OK;

                mMtProgress.MtProgress_Init(mProgress);

                for (uint i = 0; i < numThreads; i++)
                {
                    if ((res = mThreads[i].CMtThread_Prepare()) != SZ_OK)
                    {
                        return(res);
                    }
                }

                for (uint i = 0; i < numThreads; i++)
                {
                    CMtThread   t  = mThreads[i];
                    CLoopThread lt = t.mThread;

                    if (!Thread_WasCreated(lt.mThread))
                    {
                        lt.mFunc = t.ThreadFunc;
                        if (lt.LoopThread_Create() != SZ_OK)
                        {
                            res = SZ_ERROR_THREAD;
                            break;
                        }
                    }
                }

                if (res == SZ_OK)
                {
                    int i;
                    for (i = 0; i < numThreads; i++)
                    {
                        CMtThread t = mThreads[i];
                        if (t.mThread.LoopThread_StartSubThread() != SZ_OK)
                        {
                            res = SZ_ERROR_THREAD;
                            Trace.MatchObjectWait(mThreads[0], "MtCoder_Code");
                            mThreads[0].mStopReading = true;
                            Trace.MatchObjectWait(mThreads[0], "MtCoder_Code");
                            break;
                        }
                    }

                    Event_Set(mThreads[0].mCanWrite);
                    Event_Set(mThreads[0].mCanRead);

                    for (int j = 0; j < i; j++)
                    {
                        mThreads[j].mThread.LoopThread_WaitSubThread();
                    }
                }

                for (uint i = 0; i < numThreads; i++)
                {
                    mThreads[i].CMtThread_CloseEvents();
                }

                return((res == SZ_OK) ? mRes : res);
            }
Example #3
0
            // CMtThread_Construct
            internal CMtThread(int index, CMtCoder mtCoder)
            {
                Trace.MatchObjectCreate(this, "CMtThread_Construct");

                mIndex = index;
                mMtCoder = mtCoder;
                mOutBuf = null;
                mInBuf = null;

                Event_Construct(out mCanRead);
                Event_Construct(out mCanWrite);

                mThread = new CLoopThread();
            }