git-svn-id: svn://db.shs.com.ru/pip@308 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -113,6 +113,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
PIMutex PIIODevice::nfp_mutex;
|
||||||
|
PIMap<PIString, PIString> PIIODevice::nfp_cache;
|
||||||
|
|
||||||
|
|
||||||
PIIODevice::PIIODevice(): PIThread() {
|
PIIODevice::PIIODevice(): PIThread() {
|
||||||
mode_ = ReadOnly;
|
mode_ = ReadOnly;
|
||||||
_init();
|
_init();
|
||||||
@@ -363,6 +367,7 @@ PIIODevice * PIIODevice::createFromFullPath(const PIString & full_path) {
|
|||||||
if (prefix == ((const PIIODevice * )d)->fullPathPrefix()) {
|
if (prefix == ((const PIIODevice * )d)->fullPathPrefix()) {
|
||||||
PIIODevice * nd = ((const PIIODevice * )d)->copy();
|
PIIODevice * nd = ((const PIIODevice * )d)->copy();
|
||||||
if (nd) nd->configureFromFullPath(full_path.mid(prefix.length() + 3));
|
if (nd) nd->configureFromFullPath(full_path.mid(prefix.length() + 3));
|
||||||
|
cacheFullPath(full_path, nd);
|
||||||
return nd;
|
return nd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,22 +376,28 @@ PIIODevice * PIIODevice::createFromFullPath(const PIString & full_path) {
|
|||||||
|
|
||||||
|
|
||||||
PIString PIIODevice::normalizeFullPath(const PIString & full_path) {
|
PIString PIIODevice::normalizeFullPath(const PIString & full_path) {
|
||||||
static PIMutex nfp_mutex;
|
nfp_mutex.lock();
|
||||||
static PIMap<PIString, PIString> nfp_cache;
|
|
||||||
PIMutexLocker nfp_ml(nfp_mutex);
|
|
||||||
PIString ret = nfp_cache.value(full_path);
|
PIString ret = nfp_cache.value(full_path);
|
||||||
if (!ret.isEmpty())
|
if (!ret.isEmpty()) {
|
||||||
|
nfp_mutex.unlock();
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
nfp_mutex.unlock();
|
||||||
PIIODevice * d = createFromFullPath(full_path);
|
PIIODevice * d = createFromFullPath(full_path);
|
||||||
//piCout << "normalizeFullPath" << d;
|
//piCout << "normalizeFullPath" << d;
|
||||||
if (d == 0) return PIString();
|
if (d == 0) return PIString();
|
||||||
ret = d->constructFullPath();
|
ret = d->constructFullPath();
|
||||||
delete d;
|
delete d;
|
||||||
nfp_cache[full_path] = ret;
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIIODevice::cacheFullPath(const PIString & full_path, const PIIODevice * d) {
|
||||||
|
PIMutexLocker nfp_ml(nfp_mutex);
|
||||||
|
nfp_cache[full_path] = d->constructFullPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIIODevice::threadedRead(uchar *readed, int size) {
|
bool PIIODevice::threadedRead(uchar *readed, int size) {
|
||||||
// piCout << "iodevice threaded read";
|
// piCout << "iodevice threaded read";
|
||||||
if (ret_func_ != 0) return ret_func_(ret_data_, readed, size);
|
if (ret_func_ != 0) return ret_func_(ret_data_, readed, size);
|
||||||
|
|||||||
@@ -356,6 +356,7 @@ private:
|
|||||||
void begin();
|
void begin();
|
||||||
void run();
|
void run();
|
||||||
void end() {terminate();}
|
void end() {terminate();}
|
||||||
|
static void cacheFullPath(const PIString & full_path, const PIIODevice * d);
|
||||||
|
|
||||||
PITimer timer;
|
PITimer timer;
|
||||||
PITimeMeasurer tm;
|
PITimeMeasurer tm;
|
||||||
@@ -366,6 +367,9 @@ private:
|
|||||||
int readed_;
|
int readed_;
|
||||||
bool init_, thread_started_, raise_threaded_read_;
|
bool init_, thread_started_, raise_threaded_read_;
|
||||||
|
|
||||||
|
static PIMutex nfp_mutex;
|
||||||
|
static PIMap<PIString, PIString> nfp_cache;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PIIODEVICE_H
|
#endif // PIIODEVICE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user