1.1 --- a/epoc32/include/versittls.h Tue Mar 16 16:12:26 2010 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,110 +0,0 @@
1.4 -// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 -// All rights reserved.
1.6 -// This component and the accompanying materials are made available
1.7 -// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.8 -// which accompanies this distribution, and is available
1.9 -// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 -//
1.11 -// Initial Contributors:
1.12 -// Nokia Corporation - initial contribution.
1.13 -//
1.14 -// Contributors:
1.15 -//
1.16 -// Description:
1.17 -//
1.18 -
1.19 -#ifndef __VERSITTLS_H__
1.20 -#define __VERSITTLS_H__
1.21 -
1.22 -// System includes
1.23 -#include <e32base.h>
1.24 -#include <charconv.h>
1.25 -
1.26 -#include <vutil.h>
1.27 -
1.28 -class CVersitTimer;
1.29 -class CVersitAdditionalStorage;
1.30 -
1.31 -class CVersitTlsData : public CBase
1.32 -/** Versit thread local storage.
1.33 -
1.34 -This class provides a performance improvement by allowing a CVersitUnicodeUtils
1.35 -instance to be shared between parsers operating in the same thread, so that
1.36 -a new instance does not have to be created for each parser. A pointer to the
1.37 -unicode utilities object is held in thread local storage: a single word (32bits)
1.38 -of data. Each unicode utilities object is managed by an instance of this class.
1.39 -
1.40 -Every time a parser is created, CVersitParser::ConstructL() calls the
1.41 -CVersitTlsData constructor, and when the parser is destroyed the CVersitTlsData
1.42 -destructor is called. If a CVersitTlsData object exists, the constructor
1.43 -returns a pointer to it, otherwise a new one is constructed. The CVersitTlsData
1.44 -object is only destroyed when no more parsers refer to it: a count is kept,
1.45 -which is incremented every time the constructor is called and decremented each
1.46 -time the destructor is called, and the object is only destroyed when the count
1.47 -reaches zero.
1.48 -
1.49 -This class provides an additional major performance improvement
1.50 -if you are sequentially constructing and destructing multiple parsers.
1.51 -By default, when the count of parsers reaches zero, the thread local
1.52 -storage object is destroyed (even if the thread has not finished). However,
1.53 -by using the technique described below, the thread local storage object, and therefore
1.54 -the unicode utilities object, can be made to persist, significantly reducing
1.55 -the overhead of sequentially constructing and destructing parsers.
1.56 -
1.57 -The constructor needs to be called an extra time before creating any parsers,
1.58 -and the destructor needs to be called an extra time once the parsers have
1.59 -been destroyed. This has the effect of adding one to the reference count so
1.60 -that during all the parser construction and deletion the count never hits
1.61 -zero, which would trigger the TLS object's destruction.
1.62 -
1.63 -This can be implemented as follows:
1.64 -
1.65 -1. Create a thread local storage data class instance as follows:
1.66 -@code
1.67 -CVersitTlsData* versitTLS = CVersitTlsData::VersitTlsDataL();
1.68 -@endcode
1.69 -
1.70 -2. Create and delete the parsers.
1.71 -
1.72 -3. Delete the Thread Local Storage Data class instance:
1.73 -@code
1.74 -delete versitTLS;
1.75 -@endcode
1.76 -@publishedAll
1.77 -@released
1.78 -*/
1.79 - {
1.80 - friend class CVersitTimer;
1.81 -
1.82 -public:
1.83 - IMPORT_C static CVersitTlsData& VersitTlsDataL();
1.84 - IMPORT_C static void CloseVersitTlsData();
1.85 - IMPORT_C void VersitTlsDataClose();
1.86 -
1.87 -public:
1.88 - inline CVersitUnicodeUtils& UnicodeUtils()
1.89 - /** Returns a pointer to the current Unicode utilities object.
1.90 -
1.91 - @return A pointer to the current Unicode utilities object. */
1.92 - { return *iUnicodeUtils; }
1.93 -
1.94 - inline CVersitAdditionalStorage& AdditionalStorage()
1.95 - /** Returns a pointer to the additional property storage object.
1.96 -
1.97 - @return A pointer to the additional property storage. */
1.98 - {
1.99 - return *iAdditionalStorage;
1.100 - }
1.101 -
1.102 -private:
1.103 - static CVersitTlsData* NewL();
1.104 - void ConstructL();
1.105 - ~CVersitTlsData();
1.106 -
1.107 -private:
1.108 - TInt iRefCount;
1.109 - CVersitUnicodeUtils* iUnicodeUtils;
1.110 - CVersitAdditionalStorage* iAdditionalStorage;
1.111 - };
1.112 -
1.113 -#endif