Skip to content

refactor: QML GUI stack [Part 5] -> Dissolve runs in own thread + concurrent messaging and notifications - #2622

Open
RobBuchananCompPhys wants to merge 2 commits into
develop2from
dissolve2/gui2-stack/part-5-dissolve-thread
Open

RobBuchananCompPhys wants to merge 2 commits into
develop2from
dissolve2/gui2-stack/part-5-dissolve-thread

Conversation

@RobBuchananCompPhys

@RobBuchananCompPhys RobBuchananCompPhys commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

This work aims to run the Dissolve graph in its own thread, alleviating the GUI to be used as normal while the graph runs. The mechanisms to do this are pretty straightforward. We spin up a new thread using the QThread class, and run the graph inside it.

The trickier bit has been live monitoring of the graph's progress. This has been done via a processComplete_ member on every Node, a std::optional<bool> allowing for the resolution of three possible states: false = process started, true = process finished, and the default, uninitialised state = 'not yet run'.

This state is sampled across all nodes by their respective NodeMessages object, at 250 ms intervals, and this fundamentally determines the notification state that the user sees for each node. Running a node resets the state, and running a node that is itself a Graph resets all the progress trackers within the graph.

I've considered writing a unit test to test this behaviour, as the fact that this introduces a change to the back end Node and Graph seems to warrant a test case. However, I'm not really sure what the best way to test the mechanism is! In practice, it will throw a hard C++ runtime exception if any illogical behaviour should occur (i.e. if the progress tracker is in a true - i.e. finished - state when we start running the node, or vice versa), so every graph we run during our unit tests in a way becomes an automatic test case for this. Since we are dealing with a private member, we can't really mutate it externally to try and force the wrong behaviour.

Additionally, this system is principally of use to the UI notifications, and doesn't get called anywhere else, so I had considered wrapping the Node::started()/Node::finished() calls inside a compiler-level IF GUI etc..., but then realised that this progress might also be useful for reporting to some sort of console progress bar when running the CLI version too.

@RobBuchananCompPhys
RobBuchananCompPhys added this pull request to stack #2609 September 25, 2026 15:04
@RobBuchananCompPhys
RobBuchananCompPhys force-pushed the dissolve2/gui2-stack/part-5-dissolve-thread branch from 678eeb3 to 549aa3c Compare September 25, 2026 15:15
@RobBuchananCompPhys
RobBuchananCompPhys force-pushed the dissolve2/gui2-stack/part-5-dissolve-thread branch from 549aa3c to 04a8994 Compare October 5, 2026 12:07
@RobBuchananCompPhys
RobBuchananCompPhys force-pushed the dissolve2/gui2-stack/part-5-dissolve-thread branch from 2ae78d6 to 21e7f48 Compare October 6, 2026 14:29
Base automatically changed from dissolve2/gui2-stack/part-4-qml-dev-phase2 to develop2 October 7, 2026 09:51
@RobBuchananCompPhys
RobBuchananCompPhys force-pushed the dissolve2/gui2-stack/part-5-dissolve-thread branch 2 times, most recently from 9ce66c0 to c7bf272 Compare October 7, 2026 14:04
@RobBuchananCompPhys
RobBuchananCompPhys marked this pull request as ready for review October 8, 2026 09:43
@RobBuchananCompPhys
RobBuchananCompPhys force-pushed the dissolve2/gui2-stack/part-5-dissolve-thread branch from ab7b338 to ebde573 Compare October 8, 2026 09:44

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant