# # # patch "src/monotone/MonotoneThread.cpp" # from [08883e65cab05f04143b8c06e362bc7b7d4cfac7] # to [13c307568e9ebe5d05cd5ce6e814f97997bcfa80] # # patch "src/monotone/MonotoneThread.h" # from [bcdcc6b9ea9e6425419793182d1fc5541716f243] # to [6ffa825b951bffca47575c53e9d80887331f9c98] # ============================================================ --- src/monotone/MonotoneThread.cpp 08883e65cab05f04143b8c06e362bc7b7d4cfac7 +++ src/monotone/MonotoneThread.cpp 13c307568e9ebe5d05cd5ce6e814f97997bcfa80 @@ -278,25 +278,41 @@ void MonotoneThread::abort() // FIXME: I think we need to care somehow if we pass // threads around - i.e. use shared ptrs or something +MonotoneThread * MonotoneThreadManager::getThreadForWorkspace(const QString & workspace) +{ + QString normalizedWorkspace = normalizeWorkspacePath(workspace); + QString databaseFile = getDatabaseFilePath(normalizedWorkspace); + return getThread(databaseFile, workspace); +} + +MonotoneThread * MonotoneThreadManager::getThreadForDatabase(const QString & database) +{ + return getThread(database, QString()); +} + MonotoneThread * MonotoneThreadManager::getThread(const QString & database, const QString & workspace) { - if (!threadMap.contains(database)) + // FIXME: since we cannot set the workspace directory after we've + // started the process, we need to ensure that each workspace runs with + // its own process + QString ident = database + "|" + workspace; + if (!threadMap.contains(ident)) { // TODO: connect to started(int) and aborted(int, ...) here // and wait for started() MonotoneThread * thread = new MonotoneThread(threadNumber++, mtnPath, database, workspace); - threadMap.insert(database, thread); + threadMap.insert(ident, thread); } // TODO: we may want to add support for multiple threads for one // and the same database here in the future... - MonotoneThread * thread = threadMap.value(database); + MonotoneThread * thread = threadMap.value(ident); if (!thread->isRunning()) { // TODO: disconnect from started(int) and aborted(int, ...) here delete thread; - threadMap.remove(database); + threadMap.remove(ident); // up to the next round return getThread(database, workspace); } ============================================================ --- src/monotone/MonotoneThread.h bcdcc6b9ea9e6425419793182d1fc5541716f243 +++ src/monotone/MonotoneThread.h 6ffa825b951bffca47575c53e9d80887331f9c98 @@ -119,11 +119,14 @@ public: inline void setMtnBinaryPath(const QString & path) { mtnPath = path; } + MonotoneThread * getThreadForWorkspace(const QString &); + MonotoneThread * getThreadForDatabase(const QString &); + MonotoneThread * getThread(const QString &, const QString &); + +private: QString getDatabaseFilePath(const QString &); QString normalizeWorkspacePath(const QString &); - MonotoneThread * getThread(const QString &, const QString & workspace = QString()); -private: QMap threadMap; QMap workspaceMap; QString mtnPath;