|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <mb_thread.h> |
|
17 #include <e32debug.h> |
|
18 #include <es_mbman.h> |
|
19 |
|
20 using namespace CommsFW; |
|
21 |
|
22 EXPORT_C TInt RCFThread::Create(const TDesC& aName, TThreadFunction aOtherThreadFunction, |
|
23 TInt aStackSize, RHeap* aHeap, TAny* aModuleArgs) |
|
24 /** |
|
25 Derived implementation of RThread::Create, which processes some specific |
|
26 data for the new thread before calling the RThread::Create. |
|
27 @param aName Name of the new thread. |
|
28 @param aOtherThreadFunction Main thread-function. |
|
29 @param aStackSize Initial size of the thread stack. |
|
30 @param aHeap The heap for the thread. |
|
31 @param aModuleArgs Pointer given as argument to aOtherThreadFunction. |
|
32 @see RThread |
|
33 @see TThreadFunction |
|
34 @see RHeap |
|
35 @publishedPartner |
|
36 @released |
|
37 */ |
|
38 { |
|
39 iStartupInfo.iMBufManager = CMBufManager::Context(); |
|
40 __CFLOG_STMT( iStartupInfo.iCFLogIf = CCFLogIf::Context()); |
|
41 if( iStartupInfo.iMBufManager == NULL ) |
|
42 return KErrNotFound; |
|
43 // Check to make sure the logger is available. |
|
44 #ifdef __CFLOG_ACTIVE |
|
45 if( !iStartupInfo.iCFLogIf ) |
|
46 { |
|
47 RDebug::Print( _L( "RCFThread::Create - the log interface was not found. This normally means that the logging version of commsfw.dll has been mixed with a stub version of cflog.dll. See CommsDebugUtility How-To Document FAQ section for details on enabling logging in a release build." ) ); |
|
48 |
|
49 return KErrNotFound; |
|
50 } |
|
51 #endif |
|
52 |
|
53 iStartupInfo.iOtherThreadFunction = aOtherThreadFunction; |
|
54 iStartupInfo.iModuleArgs = aModuleArgs; |
|
55 return RThread::Create(aName, RCFThreadFunction, aStackSize, aHeap, &iStartupInfo); |
|
56 }; |
|
57 |
|
58 EXPORT_C TInt RCFThread::Create(const TDesC& aName, TThreadFunction aOtherThreadFunction, |
|
59 TInt aStackSize, TInt aMinHeapSize, TInt aMaxHeapSize, TAny* aModuleArgs) |
|
60 /** |
|
61 Derived implementation of RThread::Create, which processes some specific |
|
62 data for the new thread before calling the RThread::Create |
|
63 @param aName Name of the new thread. |
|
64 @param aOtherThreadFunction Main thread-function. |
|
65 @param aStackSize Initial size of the thread stack. |
|
66 @param aMinHeapSize Minimum size of the heap that will be created for the thread. |
|
67 @param aMaxHeapSize Maximum size of the heap that will be created for the thread. |
|
68 @param aModuleArgs Pointer given as argument to aOtherThreadFunction. |
|
69 @see RThread |
|
70 @see TThreadFunction |
|
71 @publishedPartner |
|
72 @released |
|
73 */ |
|
74 { |
|
75 iStartupInfo.iMBufManager = CMBufManager::Context(); |
|
76 __CFLOG_STMT( iStartupInfo.iCFLogIf = CCFLogIf::Context()); |
|
77 if( iStartupInfo.iMBufManager == NULL ) |
|
78 return KErrNotFound; |
|
79 // Check to make sure the logger is available. |
|
80 #ifdef __CFLOG_ACTIVE |
|
81 if( !iStartupInfo.iCFLogIf ) |
|
82 { |
|
83 RDebug::Print( _L( "RCFThread::Create - the log interface was not found. This normally means that the logging version of commsfw.dll has been mixed with a stub version of cflog.dll. See CommsDebugUtility How-To Document FAQ section for details on enabling logging in a release build." ) ); |
|
84 |
|
85 return KErrNotFound; |
|
86 } |
|
87 #endif |
|
88 |
|
89 iStartupInfo.iOtherThreadFunction = aOtherThreadFunction; |
|
90 iStartupInfo.iModuleArgs = aModuleArgs; |
|
91 return RThread::Create(aName, RCFThreadFunction, aStackSize, aMinHeapSize, aMaxHeapSize, &iStartupInfo); |
|
92 }; |
|
93 |
|
94 TInt RCFThread::RCFThreadFunction(TAny* aStartupInfo ) |
|
95 /** |
|
96 Intermediate function which masquerades as the main thread function in order to |
|
97 perform some specific actions for the new thread in the correct context before |
|
98 calling the new thread's actual main thread function |
|
99 @param aStartupInfo structure containing pointers to MBufMger and CFlog. |
|
100 @see RCFThread::ThreadStartupInfo |
|
101 @internalComponent |
|
102 */ |
|
103 { |
|
104 ThreadStartupInfo* startInfo = reinterpret_cast<ThreadStartupInfo*>(aStartupInfo); |
|
105 startInfo->iMBufManager->SetContext(); |
|
106 __CFLOG_STMT( startInfo->iCFLogIf->SetContext();) |
|
107 __CFLOG_OPEN; |
|
108 TInt result = startInfo->iOtherThreadFunction(startInfo->iModuleArgs); |
|
109 __CFLOG_CLOSE; |
|
110 return result; |
|
111 }; |
|
112 |