linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #06463
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3191: Satisfy some boost lockfree requirements, could fix bugs on heavy load
------------------------------------------------------------
revno: 3191
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2013-01-27 18:45:34 +0100
message:
Satisfy some boost lockfree requirements, could fix bugs on heavy load
modified:
changelog.txt
dcpp/QueueManager.cpp
dcpp/QueueManager.h
dwt/include/dwt/Application.h
dwt/src/Application.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt 2013-01-25 20:29:34 +0000
+++ changelog.txt 2013-01-27 17:45:34 +0000
@@ -6,7 +6,7 @@
* Improve the plugin API (poy, crise)
* Delete "View as text" files only when their window is closed (poy)
* Fix queue matching when files have the same TTH but a different size (thanks irainman)
-* Update Boost to version 1.52
+* Update Boost to version 1.52 and atomic&lockfree to the version in trunk
* Restore "Requesting" messages in the transfer list
* [L#1071363] Apply link & plugin formatting to status messages (crise, poy)
* [L#311818] Share file name duplicates due to directory merges (poy)
@@ -23,6 +23,7 @@
* Add hublist.eu to default hub lists
* Add a toolbar button to open own file list (poy)
* [L#489704] Fix invalid share sizes after a directory merge (poy)
+* Satisfy some boost lockfree requirements, could fix bugs on heavy load
Note: The hash registry will be upgraded when running this version for the
first time. Make sure all your drives are connected to avoid re-hashing.
=== modified file 'dcpp/QueueManager.cpp'
--- dcpp/QueueManager.cpp 2013-01-18 21:28:38 +0000
+++ dcpp/QueueManager.cpp 2013-01-27 17:45:34 +0000
@@ -300,7 +300,7 @@
}
void QueueManager::FileMover::moveFile(const string& source, const string& target) {
- files.push(make_pair(source, target));
+ files.push(new FilePair(source, target));
if(!active.test_and_set()) {
start();
}
@@ -310,18 +310,18 @@
ScopedFunctor([this] { active.clear(); });
while(true) {
- FilePair next;
+ unique_ptr<FilePair> next;
if(!files.pop(next)) {
return 0;
}
- moveFile_(next.first, next.second);
+ moveFile_(next->first, next->second);
}
return 0;
}
void QueueManager::Rechecker::add(const string& file) {
- files.push(file);
+ files.push(new string(file));
if(!active.test_and_set()) {
start();
}
@@ -331,7 +331,7 @@
ScopedFunctor([this] { active.clear(); });
while(true) {
- string file;
+ unique_ptr<string> file;
if(!files.pop(file)) {
return 0;
}
@@ -343,12 +343,12 @@
{
Lock l(qm->cs);
- q = qm->fileQueue.find(file);
+ q = qm->fileQueue.find(*file);
if(!q || q->isSet(QueueItem::FLAG_USER_LIST))
continue;
qm->fire(QueueManagerListener::RecheckStarted(), q->getTarget());
- dcdebug("Rechecking %s\n", file.c_str());
+ dcdebug("Rechecking %s\n", file->c_str());
tempSize = File::getSize(q->getTempTarget());
@@ -383,7 +383,7 @@
Lock l(qm->cs);
// get q again in case it has been (re)moved
- q = qm->fileQueue.find(file);
+ q = qm->fileQueue.find(*file);
if(!q)
continue;
@@ -411,7 +411,7 @@
Lock l(qm->cs);
// get q again in case it has been (re)moved
- q = qm->fileQueue.find(file);
+ q = qm->fileQueue.find(*file);
if(!q)
continue;
=== modified file 'dcpp/QueueManager.h'
--- dcpp/QueueManager.h 2013-01-18 21:28:38 +0000
+++ dcpp/QueueManager.h 2013-01-27 17:45:34 +0000
@@ -155,7 +155,7 @@
private:
static atomic_flag active;
typedef pair<string, string> FilePair;
- boost::lockfree::queue<FilePair> files;
+ boost::lockfree::queue<FilePair*> files;
} mover;
class Rechecker : public Thread {
@@ -174,7 +174,7 @@
private:
QueueManager* qm;
static atomic_flag active;
- boost::lockfree::queue<string> files;
+ boost::lockfree::queue<string*> files;
} rechecker;
/** All queue items by target */
=== modified file 'dwt/include/dwt/Application.h'
--- dwt/include/dwt/Application.h 2013-01-18 21:28:38 +0000
+++ dwt/include/dwt/Application.h 2013-01-27 17:45:34 +0000
@@ -191,7 +191,7 @@
// The according signals we must raise, go in this vector.
std::vector<Callback> itsVSignals;
- boost::lockfree::queue<Callback> tasks;
+ boost::lockfree::queue<Callback*> tasks;
FilterList filters;
=== modified file 'dwt/src/Application.cpp'
--- dwt/src/Application.cpp 2013-01-18 21:28:38 +0000
+++ dwt/src/Application.cpp 2013-01-27 17:45:34 +0000
@@ -41,8 +41,12 @@
#include <dwt/widgets/Control.h>
#include <assert.h>
+#include <memory>
+
namespace dwt {
+using std::unique_ptr;
+
Application* Application::itsInstance = 0;
HANDLE Application::itsMutex = 0;
@@ -226,9 +230,9 @@
}
bool Application::dispatchAsync() {
- Callback callback;
+ unique_ptr<Callback> callback;
if(tasks.pop(callback)) {
- callback();
+ (*callback)();
return true;
}
return false;
@@ -237,7 +241,7 @@
#ifndef DWT_SHARED
void Application::callAsync(const Callback& callback) {
- tasks.push(callback);
+ tasks.push(new Callback(callback));
wake();
}