# # # patch "src/monotone/MonotoneThread.h" # from [fee97aaba84dc796ce523e2fe88b17337c6a7b27] # to [cc5aac5ed9e210bace10ad2239cdaf71732bf26f] # ============================================================ --- src/monotone/MonotoneThread.h fee97aaba84dc796ce523e2fe88b17337c6a7b27 +++ src/monotone/MonotoneThread.h cc5aac5ed9e210bace10ad2239cdaf71732bf26f @@ -39,20 +39,46 @@ public: MonotoneTask(const ByteArrayList &); MonotoneTask(const ByteArrayList &, const ByteArrayList &); + //! sets the command number of this task (increased internally by the thread) void setCommandNumber(int num) { commandNumber = num; } + + //! sets the thread number to identify the thread void setThreadNumber(int num) { threadNumber = num; } + + //! sets the raw command output void setOutput(const QByteArray & out) { output = out; } + + //! sets the return code of the command void setReturnCode(int code) { returnCode = code; } + + //! marks that the task has been finished void setFinished() { finished = true; } + //! returns the command input stdio-encoded QByteArray getEncodedInput() const; + + //! returns the given arguments for the command ByteArrayList getArguments() const { return arguments; } + + //! returns the given options for the command ByteArrayList getOptions() const { return options; } + + //! returns the raw monotone output QByteArray getOutput() const { return output; } + + //! returns the monotone output as utf-8 encoded string QString getOutputUtf8() const { return QString::fromUtf8(output); } + + //! returns the command's return code int getReturnCode() const { return returnCode; } + + //! returns the command's number (i.e. sequential number of the running mtn process) int getCommandNumber() const { return commandNumber; } + + //! returns the number of the thread on which this task should/has been run int getThreadNumber() const { return threadNumber; } + + //! true, if the task has already been completed bool isFinished() const { return finished; } private: @@ -76,22 +102,43 @@ public: public: MonotoneThread(int, const QString &, const QString &, const QString & workspace = QString()); ~MonotoneThread(); + + //! returns the database filepath which has been loaded by this thread inline QString getDatabaseFilePath() const { return databasePath; } + + //! returns the workspace which has been set by this thread for the running instance (if any) inline QString getWorkspacePath() const { return workspacePath; } + + //! returns the amount of tasks which are in the queue inline int getQueueCount() const { return queue.size(); } + + //! returns the thread's ident number inline int getThreadNumber() const { return threadNumber; } protected: void run(); public slots: + //! enqueue a new task for this thread int enqueueTask(const MonotoneTask &); + //! abort task execution on this thread + /*! + ATTENTION: all unfinished tasks will be aborted! + \sa taskAborted() + */ void abort(); signals: + //! signaled if a task has been finished void taskFinished(const MonotoneTask &); + + //! signaled for each task which has been aborted void taskAborted(const MonotoneTask &); + + //! signaled if the internal mtn process was successfully started void started(int); + + //! signaled if the interal mtn process was aborted (i.e. crashed) void aborted(int, QProcess::ProcessError, const QString &); private: @@ -117,14 +164,20 @@ public: MonotoneThreadManager(const QString & p) : mtnPath(p), threadNumber(0) {}; ~MonotoneThreadManager() {}; + //! set the path to the monotone binary to use for all threads inline void setMtnBinaryPath(const QString & path) { mtnPath = path; } + + //! returns the database filepath for a given workspace path DatabaseFile getDatabaseFilePath(const WorkspacePath &); + //! returns an appropriate MonotoneThread for the given workspace MonotoneThread * getThreadForWorkspace(const WorkspacePath &); + + //! returns an appropriate MonotoneThread for the given database MonotoneThread * getThreadForDatabase(const DatabaseFile &); - MonotoneThread * getThread(const DatabaseFile &, const WorkspacePath &); private: + MonotoneThread * getThread(const DatabaseFile &, const WorkspacePath &); WorkspacePath normalizeWorkspacePath(const WorkspacePath &); QMap threadMap;