]> granicus.if.org Git - transmission/commit
Refactor RPC requests code for proper queueing (patch by intelfx @ GH-10)
authorMike Gelfand <mikedld@mikedld.com>
Tue, 19 Apr 2016 20:41:59 +0000 (20:41 +0000)
committerMike Gelfand <mikedld@mikedld.com>
Tue, 19 Apr 2016 20:41:59 +0000 (20:41 +0000)
commit2b917de65b378fe458c2c6a9d77dcbed89b056cc
tree1395e97ef5caac5c22bfb25600c503ab3c645b5a
parent66285a525ba8c78b73c7c7fd340a314757624c50
Refactor RPC requests code for proper queueing (patch by intelfx @ GH-10)

This refactoring is driven by the need to be able to do true queued RPC calls
(where each successive call uses the result of the previous).

Currently, such queueing of requests is done by assigning them special "magic"
tag numbers, which are then intercepted in one big switch() statement and acted
upon. This (aside from making code greatly unclear) effectively makes each such
queue a singleton, because state passing is restricted to global variables.

We refactor RpcClient to assign an unique tag to each remote call, and then
abstract all the call<->response matching with Qt's future/promise mechanism.

Finally, we introduce a "RPC request queue" class (RpcQueue) which is built on
top of QFutureWatcher and C++11's <functional> library. This class maintains
a queue of functions, where each function receives an RPC response, does
necessary processing, performs another call and finally returns its future.
14 files changed:
qt/AddData.cc
qt/AddData.h
qt/CMakeLists.txt
qt/FreeSpaceLabel.cc
qt/FreeSpaceLabel.h
qt/MainWindow.cc
qt/MainWindow.h
qt/RpcClient.cc
qt/RpcClient.h
qt/RpcQueue.cc [new file with mode: 0644]
qt/RpcQueue.h [new file with mode: 0644]
qt/Session.cc
qt/Session.h
qt/qtr.pro