Thinker-Qt
Background calculation library for Qt 4.5+. Creates a QObject-derived class that leverages QSharedData model in order to simplify coding for the following situation: more…
- Programmer has a calculation that they want to run in the background without blocking the main thread
- The end result of the calculation is important... but the incremental results are also useful
- Events on main thread may trigger conditions that make it desirable to abandon the previously requested calculation (and probably start a different one)
(For an example, consider Qt’s Mandelbrot sample.)
Thread abstractions such as QRunnable and “Task oriented” libraries such as Intel Threaded Building Blocks don’t specifically this case. They have no start/stop interface after submitting tasks to thread pools.
Thinker-Qt automatically handles the assignment of coroutines to threads and reduces the synchronization overhead in working with snapshots of their internal state from the main thread.
thinker-qt
Main repository for Thinker-Qt
-
Cloning this repository:
git clone git://gitorious.org/thinker-qt/thinker-qt.git thinker-qt cd thinker-qt
Add this repository as a remote to an existing local repository:
git remote add thinker-qt git://gitorious.org/thinker-qt/thinker-qt.git git fetch thinker-qt git checkout -b my-local-tracking-branch thinker-qt/master_or_other_branch
Activities 
-
Monday February 01 2010
-
Push
03:01
-
-
Friday January 22 2010
-
Push
05:23
-
Push
05:02
-
Push
04:11
-
-
Thursday January 21 2010
-
Comment
23:26
hostilefork commented on thinker-qt/thinker-qt/458eb50
Ok technically, since update()s are queued...it's probably not that significant to be clearing it at this moment. Would've been better to grab the...
-
Comment
22:32
hostilefork commented on thinker-qt/thinker-qt/458eb50
Indeed, it is generally nice to make the Thinker object a friend of the state object! You can imagine that these are member variables of the Think...
-
Comment
22:12
elj commented on thinker-qt/thinker-qt/458eb50
It's nice to have friends!
-
Comment
21:56
hostilefork commented on thinker-qt/thinker-qt/458eb50
Data passed into a Thinker's constructor and then saved as internal state doesn't need to be protected with a mutex in Thinker-Qt, so this is unnec...
-
Comment
21:55
hostilefork commented on thinker-qt/thinker-qt/458eb50
This concept of "restart" doesn't exist for a Thinker. If you want to do a new computation, you cancel the old one and start a new one. ...
-
Comment
21:52
hostilefork commented on thinker-qt/thinker-qt/458eb50
This routine is just being moved to the MandelbrotWidget file. There were no changes.
-
Comment
21:52
hostilefork commented on thinker-qt/thinker-qt/458eb50
This routine is just being moved from the RenderThread file. There were no changes.
-
Comment
21:01
hostilefork commented on thinker-qt/thinker-qt/458eb50
Because a Thinker periodically polls for cancels/pauses in a cooperative-multitasking way, it won't necessarily stop on a dime. So an interesting ...
-
Comment
20:35
hostilefork commented on thinker-qt/thinker-qt/458eb50
Taking snapshots is central to Thinker-Qt, and if no write to the calculation state happens while you're holding onto it then it's essentially free...
-
Comment
20:28
hostilefork commented on thinker-qt/thinker-qt/458eb50
Deriving from a Thinker parameterized with the calculation state is what you do. Behind the scenes you get the snapshotting and automatic signaling.
-
Comment
20:24
hostilefork commented on thinker-qt/thinker-qt/458eb50
The calculation state is really just QSharedData, but I use "SnapshottableData" because I wanted a polymorphic base class. It's QSharedD...
-
Comment
20:23
hostilefork commented on thinker-qt/thinker-qt/458eb50
(Although git put this line in a weird place, it's the end of the mandelbrot calculation loop.) You might wonder why done() is a signal and not a ...
-
Comment
20:19
hostilefork commented on thinker-qt/thinker-qt/458eb50
In the original Mandelbrot sample, if the GUI thread was unable to process images faster than the RenderThread could produce them, you'd use memory...
-
Comment
20:10
hostilefork commented on thinker-qt/thinker-qt/458eb50
No emit is required here. The unlock will queue a written() signal to those who are listening, and it will be throttled appropriately.
-
Comment
20:09
hostilefork commented on thinker-qt/thinker-qt/458eb50
Although the internals of ThinkerQt use QSharedDataPointer and are thread safe with respect to writes, it may be the case that your program's seman...
-
Comment
20:07
hostilefork commented on thinker-qt/thinker-qt/458eb50
If you are nested in a function and have exception handling enabled, the routine pollForStopException() is a shortcut that throws an exception whic...
-
Comment
20:05
hostilefork commented on thinker-qt/thinker-qt/458eb50
wasPauseRequested() covers both the cases of pause and cancellation requests. (Cancellation will work with any Thinker but resuming after a pause ...
-
Comment
20:02
hostilefork commented on thinker-qt/thinker-qt/458eb50
The sooner you can clear() a snapshot pointer, the better. It reduces the risk of a write happening in the background calculation while you're hol...
-
Comment
20:00
hostilefork commented on thinker-qt/thinker-qt/458eb50
Riffing off of QtConcurrent's idea of using the word "Future", I use the word "Present" to describe the object handed back from...
-
Comment
19:56
hostilefork commented on thinker-qt/thinker-qt/458eb50
I'm currently following the convention of QFuture, where there is no implicit cancellation when objects holding references to Thinkers are destroye...
-
Comment
19:53
hostilefork commented on thinker-qt/thinker-qt/458eb50
The written() signal is automatically generated when a background calculation writes to its state. So if that calculation is in a tight loop you c...
-
Comment
19:47
hostilefork commented on thinker-qt/thinker-qt/458eb50
The Thinker::Watcher parallels QFutureWatcher by letting you know when data updates are available (although you can take snapshots at any time you ...
-
Comment
19:43
hostilefork commented on thinker-qt/thinker-qt/458eb50
To make sure we build this colormap only once, we now create it in the QWidget and pass it as a parameter. That's because unlike the long-running ...
-
Comment
19:38
hostilefork commented on thinker-qt/thinker-qt/458eb50
Thinker-Qt doesn't use signal and slot parameters to exchange data between threads. Instead, it leverages the ability to make copy-on-write "...
-
Comment
19:28
hostilefork commented on thinker-qt/thinker-qt/458eb50
Please feel free to comment inline on the source! To do so, click in the line-number area to the left on a line which is indicated as having chang...
-
Push
19:12
-

