diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/consumer_8cpp-source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/consumer_8cpp-source.html Tue Mar 30 11:56:28 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ - - -TB10.1 Example Applications: examples/Base/IPC/condvar/condvarlocal/src/consumer.cpp Source File - - - - -

examples/Base/IPC/condvar/condvarlocal/src/consumer.cpp

Go to the documentation of this file.
00001 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
-00002 // All rights reserved.
-00003 // This component and the accompanying materials are made available
-00004 // under the terms of "Eclipse Public License v1.0"
-00005 // which accompanies this distribution, and is available
-00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
-00007 //
-00008 // Initial Contributors:
-00009 // Nokia Corporation - initial contribution.
-00010 //
-00011 // Contributors:
-00012 //
-00013 // Description:
-00014 // Contains the definition of member functions of the CConsumer class.
-00015 //
-00016 
-00017 
-00018 
-00023 #include "consumer.h"
-00024 
-00031 CConsumer* CConsumer::NewL(CConsoleBase* aConsole,CQueue* aTokens)
-00032         {
-00033         CConsumer* self = new (ELeave)CConsumer;
-00034         CleanupStack::PushL(self);
-00035         self->ConstructL(aConsole,aTokens);
-00036         CleanupStack::Pop(self);
-00037         return self;
-00038         }
-00039 
-00051 void CConsumer::ConstructL(CConsoleBase* aConsole,CQueue* aTokens)
-00052         {
-00053         iConsole = aConsole;
-00054         iQueue = aTokens;
-00055 
-00056         // Create an object of the CPeriodic class.
-00057         iPeriodicCons = CPeriodic::NewL(CActive::EPriorityUserInput);
-00058 
-00059         // Create the Consumer thread.
-00060         _LIT(KConsumer,"ConsumerThread");
-00061         User::LeaveIfError(iConsThread.Create(KConsumer,ConsThreadFunc,KDefaultStackSize,KMinHeapSize,256*KMinHeapSize,iQueue,EOwnerThread));
-00062         iConsThread.SetPriority(EPriorityMore);
-00063 
-00064         // Make the Consumer thread more intensive than the Producer thread.
-00065         // Consumer thread frequency is twice the Producer thread frequency.
-00066         // Associate RemoveFunction() as the call back function for the iPeriodicCons object.
-00067         iPeriodicCons->Start(2000000,2000000,TCallBack(RemoveFunction,this));
-00068         }
-00069 
-00073 CConsumer::CConsumer()
-00074         {
-00075         }
-00076 
-00082 TInt CConsumer::ConsThreadFunc(TAny* aPtr)
-00083         {
-00084         // The while loop mechanism ensures that the thread performs the CQueue::Remove() operation each time RThread::Resume() is invoked on the thread handle.
-00085         while(true)
-00086                 {
-00087                 CQueue* ptr = (CQueue*)aPtr;
-00088                 __ASSERT_ALWAYS(ptr,User::Panic(KTxtPanic,-1));
-00089                 // Remove a token from the queue.
-00090                 ptr->Remove();
-00091                 // Suspend the thread.
-00092                 RThread().Suspend();
-00093                 }
-00094         return KErrNone;
-00095         }
-00096 
-00097 
-00101 void CConsumer::ResumeCons()
-00102         {
-00103         // Call the RThread::Resume() function on the consumer thread.
-00104         // Control goes to the CConsumer::ConsThreadFunc() function after this statement.
-00105         iConsThread.Resume();
-00106         }
-00107 
-00111 CConsumer::~CConsumer()
-00112         {
-00113         iConsThread.Kill(KErrCancel);
-00114         delete iPeriodicCons;
-00115         }
-00116 
-00117 
-00123 TInt CConsumer::RemoveFunction(TAny* aPtr)
-00124         {
-00125         CConsumer* ptr = static_cast<CConsumer*> (aPtr);
-00126         __ASSERT_ALWAYS(ptr,User::Panic(KTxtPanic,-1));
-00127         // Invoke the RThread::Resume() function on the consumer thread repeatedly.
-00128         ptr->ResumeCons();
-00129         return KErrNone;
-00130         }
-

Generated on Thu Jan 21 10:32:56 2010 for TB10.1 Example Applications by  - -doxygen 1.5.3
- -