850 { |
850 { |
851 TInt pos = FindRepositoryInfo(aUid); |
851 TInt pos = FindRepositoryInfo(aUid); |
852 return (pos!=KErrNotFound) ? iRepositoryInfo[pos] : NULL; |
852 return (pos!=KErrNotFound) ? iRepositoryInfo[pos] : NULL; |
853 } |
853 } |
854 |
854 |
|
855 void CObservable::CancelTransaction(CRepositoryTransactor& aTransactor,TUid aRepositoryUid) |
|
856 { |
|
857 if (aTransactor.IsInTransaction()) |
|
858 { |
|
859 ReleaseTransactionLock(aTransactor,aRepositoryUid); |
|
860 CObservable::TSharedRepositoryInfo* shrepinfo =SharedRepositoryInfo(aRepositoryUid); |
|
861 ASSERT(shrepinfo); |
|
862 shrepinfo->iTransactors.Remove(aTransactor); |
|
863 //Remove the link to the next transaction |
|
864 aTransactor.iLink.iNext = NULL; |
|
865 aTransactor.Deque(); |
|
866 } |
|
867 } |
|
868 |
|
869 /** Private helper method which releases any read/write locks held in the shared repository |
|
870 by this transactor. Caller must set transactor's state or remove from queue as appropriate. |
|
871 @param aTransactor transactor whose read/write locks are to be released. |
|
872 @post Any read/write locks held by transactor are released. |
|
873 */ |
|
874 void CObservable::ReleaseTransactionLock(CRepositoryTransactor& aTransactor,TUid aRepositoryUid) |
|
875 { |
|
876 CObservable::TSharedRepositoryInfo* shrepinfo = SharedRepositoryInfo(aRepositoryUid); |
|
877 ASSERT(shrepinfo); |
|
878 if (aTransactor.IsInActiveConcurrentReadWriteTransaction()) |
|
879 { |
|
880 shrepinfo->iNumActiveConcurrentReadWriteTransactions--; |
|
881 ASSERT(shrepinfo->iNumActiveConcurrentReadWriteTransactions >= 0); // sanity check |
|
882 } |
|
883 else if (aTransactor.IsInActiveReadTransaction()) |
|
884 { |
|
885 shrepinfo->iPessimisticTransactionLockCount--; |
|
886 ASSERT(shrepinfo->iPessimisticTransactionLockCount >= 0); // sanity check |
|
887 } |
|
888 else if (aTransactor.IsInActiveExclusiveReadWriteTransaction()) |
|
889 { |
|
890 // can only be one exclusive read/write transaction active (lock value -1) |
|
891 ASSERT(shrepinfo->iPessimisticTransactionLockCount == -1); |
|
892 shrepinfo->iPessimisticTransactionLockCount = 0; |
|
893 } |
|
894 } |
855 CObservable::TSharedRepositoryInfo::TSharedRepositoryInfo(TUid aUid) : |
895 CObservable::TSharedRepositoryInfo::TSharedRepositoryInfo(TUid aUid) : |
856 iRepositoryUid(aUid), iTransactors(_FOFF(CRepositoryTransactor, iLink)), |
896 iRepositoryUid(aUid), iTransactors(_FOFF(CRepositoryTransactor, iLink)), |
857 iPessimisticTransactionLockCount(0), iNumActiveConcurrentReadWriteTransactions(0) |
897 iPessimisticTransactionLockCount(0), iNumActiveConcurrentReadWriteTransactions(0) |
858 { |
898 { |
859 } |
899 } |