Commit MetaInfo

修订版842abcd8007644168854b4bcfee70a67e80d301b (tree)
时间2007-11-10 21:56:37
作者ikemo <ikemo@56b1...>
Commiterikemo

Log Message

remove lock object

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@2071 56b19765-1e22-0410-a548-a0f45d66c51a

更改概述

差异

--- a/kita/src/htmlpart.cpp
+++ b/kita/src/htmlpart.cpp
@@ -91,9 +91,6 @@ void KitaHTMLPart::clearPart()
9191
9292 if ( !m_datURL.isEmpty() ) { /* This part is opened. */
9393
94- /* don't forget to unlock previous datURL here. */
95- Kita::DatManager::unlock( m_datURL );
96-
9794 if ( m_mode == HTMLPART_MODE_MAINPART ) { /* This part is on the main thread view. */
9895
9996 /* tell Thread class that "thread is closed" */
@@ -137,9 +134,6 @@ bool KitaHTMLPart::setup( int mode, const KURL& url )
137134 Kita::DatManager::resetAbone( m_datURL );
138135 }
139136
140- /* Lock datURL. Don't forget to unlock it later ! */
141- Kita::DatManager::lock ( m_datURL );
142-
143137 /* create HTML Document */
144138 createHTMLDocument();
145139
--- a/kita/src/libkita/datinfo.cpp
+++ b/kita/src/libkita/datinfo.cpp
@@ -83,17 +83,9 @@ DatInfo::~DatInfo()
8383 /* Usually, don't call this. */ /* public */
8484 void DatInfo::init()
8585 {
86- QMutexLocker locker( &m_mutex );
87-
8886 return initPrivate( TRUE );
8987 }
9088
91-/* public */
92-void DatInfo::wait()
93-{
94- QMutexLocker locker( &m_mutex );
95-}
96-
9789 /* Init. If loadCache = TRUE, load data from cache. */ /* private */
9890 void DatInfo::initPrivate( bool loadCache )
9991 {
@@ -102,7 +94,6 @@ void DatInfo::initPrivate( bool loadCache )
10294
10395 /* init variables */
10496 m_broken = FALSE;
105- m_lock = 0;
10697 m_nowLoading = FALSE;
10798 m_lastLine = QString::null;
10899
@@ -176,8 +167,6 @@ void DatInfo::deleteAccessJob()
176167 /* public */
177168 const KURL& DatInfo::url()
178169 {
179- QMutexLocker locker( &m_mutex );
180-
181170 return m_datURL;
182171 }
183172
@@ -196,12 +185,10 @@ const KURL& DatInfo::url()
196185 DatInfo emits the finishLoad signal to the parent object */ /* public */
197186 bool DatInfo::updateCache( const QObject* parent )
198187 {
199- QMutexLocker locker( &m_mutex );
200188 if ( m_access == NULL ) return FALSE;
201189 if ( m_nowLoading ) return FALSE;
202190
203191 m_nowLoading = TRUE;
204- m_lock++; /* By locking, DatManager can't delete this while loading. */
205192
206193 connect( this, SIGNAL( receiveData() ),
207194 parent, SLOT( slotReceiveData() ) );
@@ -309,15 +296,12 @@ void DatInfo::slotFinishLoad()
309296 /* disconnect signals */
310297 disconnect( SIGNAL( receiveData() ) );
311298 disconnect( SIGNAL( finishLoad() ) );
312-
313- if ( m_lock ) m_lock--;
314299 }
315300
316301
317302 /* public */
318303 int DatInfo::getResponseCode()
319304 {
320- QMutexLocker locker( &m_mutex );
321305 if ( m_access == NULL ) return 0;
322306
323307 return m_access->responseCode();
@@ -327,7 +311,6 @@ int DatInfo::getResponseCode()
327311 /* public */
328312 int DatInfo::getServerTime()
329313 {
330- QMutexLocker locker( &m_mutex );
331314 if ( m_access == NULL ) return 0;
332315
333316 return m_access->serverTime();
@@ -337,7 +320,6 @@ int DatInfo::getServerTime()
337320 /* public */
338321 bool DatInfo::deleteCache()
339322 {
340- QMutexLocker locker( &m_mutex );
341323 if ( m_nowLoading ) return FALSE;
342324
343325 initPrivate( FALSE );
@@ -349,9 +331,6 @@ bool DatInfo::deleteCache()
349331 /* public */
350332 bool DatInfo::isLoadingNow()
351333 {
352-
353- QMutexLocker locker( &m_mutex );
354-
355334 return m_nowLoading;
356335 }
357336
@@ -371,39 +350,6 @@ void DatInfo::stopLoading()
371350 m_access->stopJob();
372351 }
373352
374-
375-
376-
377-/*---------------------------------------------------*/
378-/* locking , unlocking functions */
379-/* */
380-/* If m_lock is not 0, DatManager can't delete this. */
381-/* Don't forget to call unlock() after locking this. */
382-
383-/* They are public */
384-
385-void DatInfo::lock ()
386-{
387- QMutexLocker locker( &m_mutex );
388-
389- m_lock++;
390-}
391-
392-void DatInfo::unlock()
393-{
394- QMutexLocker locker( &m_mutex );
395-
396- if ( m_lock ) m_lock--;
397-}
398-
399-int DatInfo::isLocked()
400-{
401- QMutexLocker locker( &m_mutex );
402-
403- return m_lock;
404-}
405-
406-
407353 /*------------------------------------------------------*/
408354 /* get subject, linedata, id, body, name, HTML, etc. */
409355
@@ -411,7 +357,6 @@ int DatInfo::isLocked()
411357
412358 const QString& DatInfo::getDat( int num )
413359 {
414- QMutexLocker locker( &m_mutex );
415360 if ( !parseDat( num ) ) return QString::null;
416361
417362 return m_resDatVec[ num ].linestr;
@@ -419,7 +364,6 @@ const QString& DatInfo::getDat( int num )
419364
420365 const QString& DatInfo::getId( int num )
421366 {
422- QMutexLocker locker( &m_mutex );
423367 if ( !parseDat( num ) ) return QString::null;
424368
425369 return m_resDatVec[ num ].id;
@@ -428,7 +372,6 @@ const QString& DatInfo::getId( int num )
428372 /* plain strings of name */
429373 QString DatInfo::getPlainName( int num )
430374 {
431- QMutexLocker locker( &m_mutex );
432375 if ( !parseDat( num ) ) return QString::null;
433376
434377 return m_resDatVec[ num ].name;
@@ -438,7 +381,6 @@ QString DatInfo::getPlainName( int num )
438381 /* plain strings of title */
439382 QString DatInfo::getPlainTitle( int num )
440383 {
441- QMutexLocker locker( &m_mutex );
442384 if ( !parseDat( num ) ) return QString::null;
443385
444386 QString titleHTML;
@@ -454,7 +396,6 @@ QString DatInfo::getPlainTitle( int num )
454396 /* plain strings of body */
455397 QString DatInfo::getPlainBody( int num )
456398 {
457- QMutexLocker locker( &m_mutex );
458399 if ( !parseDat( num ) ) return QString::null;
459400
460401 QString retStr;
@@ -474,7 +415,6 @@ QString DatInfo::getPlainBody( int num )
474415
475416 int DatInfo::getHTML( int num, bool checkAbone, QString& titleHTML, QString& bodyHTML )
476417 {
477- QMutexLocker locker( &m_mutex );
478418 return getHTMLPrivate( num, checkAbone, titleHTML, bodyHTML );
479419 }
480420
@@ -522,8 +462,6 @@ int DatInfo::getHTMLPrivate( int num, bool checkAbone, QString& titleHTML, QStri
522462 return value is HTML strings */ /* public */
523463 QString DatInfo::getHTMLString( int startnum, int endnum, bool checkAbone )
524464 {
525- QMutexLocker locker( &m_mutex );
526-
527465 QString retHTML = QString::null;
528466
529467 for ( int num = startnum; num <= endnum; num++ ) {
@@ -540,8 +478,6 @@ QString DatInfo::getHTMLString( int startnum, int endnum, bool checkAbone )
540478 /* return HTML strings that have ID = strid. */ /* public */
541479 QString DatInfo::getHtmlByID( const QString& strid, int &count )
542480 {
543- QMutexLocker locker( &m_mutex );
544-
545481 QString retHTML = QString::null;
546482 count = 0;
547483
@@ -597,7 +533,6 @@ void DatInfo::getHTMLofOneRes( int num, bool checkAbone, QString& html )
597533 /* Note that this function checks Abone internally. */ /* public */
598534 QString DatInfo::getTreeByRes( const int rootnum, int& count )
599535 {
600- QMutexLocker locker( &m_mutex );
601536 return getTreeByResPrivate( rootnum, FALSE, count );
602537 }
603538
@@ -614,7 +549,6 @@ QString DatInfo::getTreeByRes( const int rootnum, int& count )
614549 /* Note that this function checks Abone internally. */ /* public */
615550 QString DatInfo::getTreeByResReverse( const int rootnum, int& count )
616551 {
617- QMutexLocker locker( &m_mutex );
618552 return getTreeByResPrivate( rootnum, TRUE, count );
619553 }
620554
@@ -742,8 +676,6 @@ int DatInfo::getViewPos()
742676 /* Note that this function checks Abone internally. */ /* public */
743677 int DatInfo::getNumByID( const QString& strid )
744678 {
745- QMutexLocker locker( &m_mutex );
746-
747679 int count = 0;
748680
749681 for ( int i = 1; i <= m_thread->readNum(); i++ ) {
@@ -761,7 +693,6 @@ int DatInfo::getNumByID( const QString& strid )
761693 /* public */
762694 int DatInfo::getDatSize()
763695 {
764- QMutexLocker locker( &m_mutex );
765696 if ( m_access == NULL ) return 0;
766697
767698 return m_access->dataSize();
@@ -778,16 +709,12 @@ const bool DatInfo::isResponsed( int num ) const
778709 /* public */
779710 bool DatInfo::isResValid( int num )
780711 {
781- QMutexLocker locker( &m_mutex );
782-
783712 return parseDat( num );
784713 }
785714
786715 /* public */
787716 bool DatInfo::isBroken()
788717 {
789- QMutexLocker locker( &m_mutex );
790-
791718 if ( m_broken ) return m_broken;
792719
793720 if ( m_access == NULL ) return FALSE;
@@ -805,7 +732,6 @@ bool DatInfo::isBroken()
805732 /* public */
806733 bool DatInfo::isResBroken( int num )
807734 {
808- QMutexLocker locker( &m_mutex );
809735 if ( !parseDat( num ) ) return FALSE;
810736
811737 return m_resDatVec[ num ].broken;
@@ -814,7 +740,6 @@ bool DatInfo::isResBroken( int num )
814740 /* ID = strid ? */ /* public */
815741 bool DatInfo::checkID( const QString& strid, int num )
816742 {
817- QMutexLocker locker( &m_mutex );
818743 if ( !parseDat( num ) ) return FALSE;
819744
820745 if ( m_resDatVec[ num ].id == strid ) return TRUE;
@@ -829,7 +754,6 @@ bool DatInfo::checkWord( QStringList& stlist, /* list of keywords */
829754 bool checkOR /* AND or OR search */
830755 )
831756 {
832- QMutexLocker locker( &m_mutex );
833757 if ( !parseDat( num ) ) return FALSE;
834758
835759 QString str_text = m_resDatVec[ num ].bodyHTML;
@@ -867,8 +791,6 @@ bool DatInfo::checkWord( QStringList& stlist, /* list of keywords */
867791
868792 void DatInfo::resetAbone()
869793 {
870- QMutexLocker locker( &m_mutex );
871-
872794 return resetAbonePrivate();
873795 }
874796
@@ -889,8 +811,6 @@ void DatInfo::resetAbonePrivate()
889811
890812 bool DatInfo::checkAbone( int num )
891813 {
892- QMutexLocker locker( &m_mutex );
893-
894814 return checkAbonePrivate( num );
895815 }
896816
--- a/kita/src/libkita/datinfo.h
+++ b/kita/src/libkita/datinfo.h
@@ -102,8 +102,6 @@ namespace Kita
102102 {
103103 Q_OBJECT
104104
105- QMutex m_mutex;
106-
107105 /* pointer of Thread class */
108106 Thread* m_thread;
109107
@@ -111,7 +109,6 @@ namespace Kita
111109 KURL m_datURL;
112110 bool m_broken;
113111 ResDatVec m_resDatVec;
114- int m_lock;
115112
116113 /* for caching */
117114 Access* m_access;
@@ -140,7 +137,6 @@ namespace Kita
140137 DatInfo( const KURL& url );
141138 ~DatInfo();
142139 void init();
143- void wait();
144140 const KURL& url();
145141
146142 /* for caching */
@@ -151,11 +147,6 @@ namespace Kita
151147 bool isLoadingNow();
152148 void stopLoading();
153149
154- /* lock, unlock */
155- void lock ();
156- void unlock();
157- int isLocked();
158-
159150 /* string data */
160151 const QString& getDat( int num );
161152 const QString& getId( int num );
--- a/kita/src/libkita/datmanager.cpp
+++ b/kita/src/libkita/datmanager.cpp
@@ -32,7 +32,6 @@ using namespace Kita;
3232 #define DMANAGER_MAXQUEUE 16
3333
3434 DatInfoList DatManager::m_datInfoList;
35-QMutex DatManager::m_mutex;
3635
3736
3837 /*-----------------------------------------------------------------------*/
@@ -90,8 +89,6 @@ DatInfo* DatManager::getDatInfo( const KURL& url, bool checkCached )
9089 without creating instance. */ /* private */
9190 DatInfo* DatManager::searchDatInfo( const KURL& url )
9291 {
93- QMutexLocker locker( &m_mutex );
94-
9592 KURL datURL = Kita::getDatURL( url );
9693 if ( datURL.isEmpty() ) return NULL; /* This url is not enrolled in BoardManager. */
9794 if ( m_datInfoList.count() == 0 ) return NULL;
@@ -124,8 +121,6 @@ DatInfo* DatManager::searchDatInfo( const KURL& url )
124121 Note that DatInfo::DatInfo() opens cached data and reads it. */ /* private */
125122 DatInfo* DatManager::enrollDatInfo( const KURL& url, bool checkCached )
126123 {
127- QMutexLocker locker( &m_mutex );
128-
129124 KURL datURL = Kita::getDatURL( url );
130125 if ( datURL.isEmpty() ) return NULL; /* This url is not enrolled in BoardManager. */
131126
@@ -149,13 +144,6 @@ DatInfo* DatManager::enrollDatInfo( const KURL& url, bool checkCached )
149144
150145 if ( ( *it ) == NULL ) continue;
151146 DatInfo* deleteInfo = ( *it );
152-
153- if ( ! deleteInfo->isLocked() ) {
154- m_datInfoList.remove( it );
155- --it;
156- deleteInfo->wait(); /* wait until DatInfo::m_mutex is released. */
157- delete deleteInfo;
158- }
159147 }
160148 }
161149
@@ -170,7 +158,6 @@ void DatManager::deleteAllDatInfo()
170158 for ( it = m_datInfoList.begin(); it != m_datInfoList.end(); ++it ) {
171159
172160 if ( ( *it ) == NULL ) continue;
173- ( *it ) ->wait();
174161 delete ( *it );
175162 }
176163 }
@@ -259,30 +246,6 @@ void DatManager::stopLoading( const KURL& url )
259246 return datInfo->stopLoading();
260247 }
261248
262-
263-
264-/*----------------------*/
265-/* lock, unlock DatInfo */
266-
267-/* public */
268-void DatManager::lock ( const KURL& url )
269-{
270- DatInfo * datInfo = getDatInfo( url );
271- if ( datInfo == NULL ) return ;
272-
273- datInfo->lock ();
274-}
275-
276-/* public */
277-void DatManager::unlock( const KURL& url )
278-{
279- DatInfo * datInfo = searchDatInfo( url );
280- if ( datInfo == NULL ) return ;
281-
282- datInfo->unlock();
283-}
284-
285-
286249 /*--------------------------------------*/
287250 /* string data */
288251
--- a/kita/src/libkita/datmanager.h
+++ b/kita/src/libkita/datmanager.h
@@ -13,7 +13,6 @@
1313
1414 #include <qvaluelist.h>
1515
16-class QMutex;
1716 class KURL;
1817 class QObject;
1918 class QStringList;
@@ -27,7 +26,6 @@ namespace Kita
2726 class DatManager
2827 {
2928 static DatInfoList m_datInfoList;
30- static QMutex m_mutex;
3129
3230 public:
3331
@@ -43,11 +41,6 @@ namespace Kita
4341 static bool isLoadingNow( const KURL& url );
4442 static void stopLoading( const KURL& url );
4543
46-
47- /* lock, unlock */
48- static void lock ( const KURL& url );
49- static void unlock( const KURL& url );
50-
5144 /* string data */
5245 static const QString& getDat( const KURL& url, int num );
5346 static const QString& getId( const KURL& url, int num );
--- a/kita/src/libkita/downloadmanager.cpp
+++ b/kita/src/libkita/downloadmanager.cpp
@@ -22,7 +22,6 @@ using namespace Kita;
2222
2323
2424 DownloadManager* DownloadManager::instance = NULL;
25-QMutex DownloadManager::m_mutex;
2625
2726
2827 /* Download file. Return value is pointer of FileLoader.
@@ -50,8 +49,6 @@ FileLoader* DownloadManager::download( const KURL& url, const QString& path,
5049 const LoaderOption& option /* option user data */
5150 )
5251 {
53- QMutexLocker locker( &m_mutex );
54-
5552 /* to use SIGNAL & SLOT, create instance of DownloadManager here. */
5653 /* ( You CANNOT use SIGNAL & SLOT without instance. ) */
5754 if ( instance == NULL ) instance = new DownloadManager();
@@ -63,8 +60,6 @@ FileLoader* DownloadManager::download( const KURL& url, const QString& path,
6360 /* public */ /* static */
6461 void DownloadManager::stopLoading( const KURL& url )
6562 {
66- QMutexLocker locker( &m_mutex );
67-
6863 if ( instance ) instance->stopLoadingPrivate( url );
6964 }
7065
--- a/kita/src/libkita/downloadmanager.h
+++ b/kita/src/libkita/downloadmanager.h
@@ -66,7 +66,6 @@ namespace Kita
6666 Q_OBJECT
6767
6868 static DownloadManager* instance;
69- static QMutex m_mutex;
7069 QPtrList< FileLoader > m_loaderList;
7170
7271 public:
--- a/kita/src/libkita/kita_misc.cpp
+++ b/kita/src/libkita/kita_misc.cpp
@@ -33,7 +33,6 @@
3333
3434 namespace Kita
3535 {
36- static QMutex codecMutex;
3736 static QCp932Codec* qcpCodec = NULL;
3837 static QTextCodec* utf8Codec = NULL;
3938 static QTextCodec* eucCodec = NULL;
@@ -61,9 +60,6 @@ namespace Kita
6160
6261 QString Kita::qcpToUnicode( const QString& str )
6362 {
64-
65- QMutexLocker locker( & Kita::codecMutex ); /* QTextCodec is not reentrant. */
66-
6763 if ( !Kita::qcpCodec ) Kita::qcpCodec = new QCp932Codec();
6864
6965 return Kita::qcpCodec->toUnicode( str );
@@ -72,9 +68,6 @@ QString Kita::qcpToUnicode( const QString& str )
7268
7369 QString Kita::utf8ToUnicode( const QString& str )
7470 {
75-
76- QMutexLocker locker( & Kita::codecMutex ); /* QTextCodec is not reentrant. */
77-
7871 if ( !Kita::utf8Codec ) Kita::utf8Codec = QTextCodec::codecForName( "utf8" );
7972
8073 return Kita::utf8Codec->toUnicode( str );
@@ -83,8 +76,6 @@ QString Kita::utf8ToUnicode( const QString& str )
8376
8477 QString Kita::eucToUnicode( const QString& str )
8578 {
86- QMutexLocker locker( & Kita::codecMutex ); /* QTextCodec is not reentrant. */
87-
8879 if ( !Kita::eucCodec ) Kita::eucCodec = QTextCodec::codecForName( "eucJP" );
8980
9081 return Kita::eucCodec->toUnicode( str );
--- a/kita/src/previewpart.cpp
+++ b/kita/src/previewpart.cpp
@@ -50,12 +50,6 @@ void KitaPreviewPart::clearPart()
5050 {
5151 slotDeletePopup();
5252
53- if ( !m_datURL.isEmpty() ) {
54- /* This part is opened. */
55-
56- /* don't forget to unlock previous datURL here. */
57- Kita::DatManager::unlock( m_datURL );
58- }
5953 m_datURL = QString::null;
6054 }
6155
@@ -67,9 +61,6 @@ bool KitaPreviewPart::setup( const KURL& url )
6761
6862 m_datURL = Kita::getDatURL( url );
6963
70- /* Lock datURL. Don't forget to unlock it later ! */
71- Kita::DatManager::lock ( m_datURL );
72-
7364 /* create HTML Document */
7465 createHTMLDocument();
7566
Show on old repository browser