examples/ForumNokia/ThreadAndActiveObjectsEx/src/threadlistener.cpp

00001 /*
00002  * Copyright © 2008 Nokia Corporation.
00003  */
00004 
00005 
00006 #include "ThreadListener.h"
00007 
00008 CThreadListener* CThreadListener::NewL(RThread& aThread)
00009     {
00010     CThreadListener* self = CThreadListener::NewLC(aThread);
00011     CleanupStack::Pop(self);
00012     return self;
00013     }
00014 
00015 CThreadListener* CThreadListener::NewLC(RThread& aThread)
00016     {
00017     CThreadListener* self = new (ELeave) CThreadListener();
00018     CleanupStack::PushL(self);
00019     self->ConstructL(aThread);
00020     return self;
00021     }
00022 
00023 // ----------------------------------------------------------------------------
00024 // CThreadListener::CThreadListener()
00025 //
00026 // Constructor.
00027 // ----------------------------------------------------------------------------
00028 CThreadListener::CThreadListener(): 
00029         CActive(EPriorityStandard)
00030         {
00031         }
00032 
00033 // ----------------------------------------------------------------------------
00034 // CThreadListener::CThreadListener()
00035 //
00036 // Destructor.
00037 // ----------------------------------------------------------------------------
00038 CThreadListener::~CThreadListener()
00039         {
00040         Cancel();
00041         iMonitoredThread.Close();
00042         }
00043 
00044 // Standard Symbian OS 2nd phase constructor
00045 void CThreadListener::ConstructL(RThread& aThread)
00046     {
00047         CActiveScheduler::Add(this);
00048         User::LeaveIfError( iMonitoredThread.Open(aThread.Id()) );
00049         iMonitoredThread.Logon(iStatus);
00050         SetActive();
00051     }
00052 
00053 
00054 // ----------------------------------------------------------------------------
00055 // CThreadListener::RunL()
00056 //
00057 // iStatus is given to ThreadOne Logon( ). 
00058 // Logon requests notification when thread1 dies, normally or otherwise.
00059 // ----------------------------------------------------------------------------
00060  void CThreadListener::RunL()
00061         {
00062         // Only in this example:
00063         // Consider any completion value as an error - exit now
00064         User::Exit(0);
00065         }
00066 
00067 // ----------------------------------------------------------------------------
00068 // CThreadListener::DoCancel()
00069 // ----------------------------------------------------------------------------
00070  void CThreadListener::DoCancel()
00071         {
00072         iMonitoredThread.LogonCancel(iStatus);
00073         }

Generated by  doxygen 1.6.2