equal
deleted
inserted
replaced
21 #endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
21 #endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
22 |
22 |
23 //=====CFsPool============================= |
23 //=====CFsPool============================= |
24 |
24 |
25 template <class T> |
25 template <class T> |
26 CFsPool<T>* CFsPool<T>::New(TInt aPoolSize) |
26 CFsPool<T>* CFsPool<T>::New(TInt aPoolSize, T*(*aNewFunction)()) |
27 { |
27 { |
28 CFsPool<T>* pool = new CFsPool<T>(); |
28 CFsPool<T>* pool = new CFsPool<T>(); |
29 if(!pool) |
29 if(!pool) |
30 return NULL; |
30 return NULL; |
31 |
31 |
32 TInt r = pool->Construct(aPoolSize); |
32 TInt r = pool->Construct(aPoolSize,aNewFunction); |
33 if(r!=KErrNone) |
33 if(r!=KErrNone) |
34 { |
34 { |
35 delete pool; |
35 delete pool; |
36 return NULL; |
36 return NULL; |
37 } |
37 } |
44 CFsPool<T>::CFsPool() |
44 CFsPool<T>::CFsPool() |
45 { |
45 { |
46 } |
46 } |
47 |
47 |
48 template <class T> |
48 template <class T> |
49 TInt CFsPool<T>::Construct(TInt aPoolSize) |
49 TInt CFsPool<T>::Construct(TInt aPoolSize,T*(*aNewFunction)()) |
50 { |
50 { |
51 TInt r = iPoolLock.CreateLocal(KNotificationPoolSize); |
51 TInt r = iPoolLock.CreateLocal(aPoolSize); |
52 if(r != KErrNone) |
52 if(r != KErrNone) |
53 return r; |
53 return r; |
54 |
54 |
55 r = iFreeList.Reserve(KNotificationPoolSize); |
55 r = iFreeList.Reserve(aPoolSize); |
56 if(r != KErrNone) |
56 if(r != KErrNone) |
57 return r; |
57 return r; |
58 |
58 |
59 TInt i = 0; |
59 TInt i = 0; |
60 while(i < aPoolSize) |
60 while(i < aPoolSize) |
61 { |
61 { |
62 T* t = T::New(); |
62 T* t = aNewFunction(); |
63 if(!t) |
63 if(!t) |
64 { |
64 { |
65 return KErrNoMemory; |
65 return KErrNoMemory; |
66 } |
66 } |
67 r = iFreeList.Append(t); |
67 r = iFreeList.Append(t); |
118 void CFsPool<T>::Unlock() |
118 void CFsPool<T>::Unlock() |
119 { |
119 { |
120 iPoolLock.Signal(); |
120 iPoolLock.Signal(); |
121 } |
121 } |
122 |
122 |
|
123 //These are needed here because the compiler needs to know which types will be |
|
124 //instantiating the template (because it's in a separate file) |
123 #ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
125 #ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
124 //This is needed here because the compiler needs to know which types will be |
|
125 //instantiating the template (because it's in a separate file) |
|
126 template class CFsPool<CFsNotificationBlock>; |
126 template class CFsPool<CFsNotificationBlock>; |
127 #endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
127 #endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
128 |
128 template class CFsPool<CFsNotificationInfo>; |