📄 oggthreadclasses.h
字号:
/*
* Copyright (c) 2005 S. Fisher
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _OggThreadClasses_h
#define _OggThreadClasses_h
#if defined(MULTI_THREAD_PLAYBACK)
#include <e32base.h>
#include <e32std.h>
// Thread commands (used by the CThreadCommandHandler)
// Only one command is defined in the base class
enum TThreadCommand
{
// Command to shutdown the thread
EThreadShutdown
};
// Interface class for handling thread panics
class MThreadPanicObserver
{
public:
// HandleThreadPanic is called when the worker thread panics
// aPanicThread is a reference to the thread that has encountered a panic
// aErr is the error code (the value returned when RThread::Logon() completes)
virtual void HandleThreadPanic(RThread& aPanicThread, TInt aErr) = 0;
};
// An active object for handling worker thread panics
// One of these is required in order to instantiate a CThreadCommandHandler
class CThreadPanicHandler : public CActive
{
public:
CThreadPanicHandler(TInt aPriority, RThread& aThread, MThreadPanicObserver& aPanicObserver);
~CThreadPanicHandler();
void HandleCaughtPanic();
private:
// From CActive
void RunL();
void DoCancel();
private:
RThread iThread;
MThreadPanicObserver& iPanicObserver;
TBool iCaughtAPanic;
};
// An active object base class for handling worker threads
// It provides support for handling commands as well as resuming and shutting down the thread
// It must have a panic handler to catch any panics generated by the worker thread
class CThreadCommandHandler : public CActive
{
public:
CThreadCommandHandler(TInt aPriority, RThread& aCommandThread, RThread& aCommandHandlerThread, CThreadPanicHandler& aPanicHandler);
~CThreadCommandHandler();
TInt ResumeCommandHandlerThread();
void ShutdownCommandHandlerThread();
void ResumeComplete(TInt aErr);
void ShutdownComplete(TInt aErr);
protected:
void ListenForCommands();
TInt SendCommand(TInt aCommand);
void RequestComplete(TInt aErr);
private:
static TInt PanicThread(TAny* aThreadData);
static void PanicThreadL(MThreadPanicObserver& aSharedData);
private:
RThread& iCommandThread;
RThread& iCommandHandlerThread;
TRequestStatus iCommandStatus;
CThreadPanicHandler& iPanicHandler;
};
#endif // MULTI_THREAD_PLAYBACK
#endif // _OggThreadClasses_h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -