diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-03 09:01:05 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-03 09:01:05 +0100 |
commit | 4d9746c828558c9f872e0aed52442863affb25d5 (patch) | |
tree | 507d7c2ba67f47d3cbbcf01a722236ff1b48426b /common/resourcecontrol.cpp | |
parent | 9cea920b7dd51867a0be0fed2f461b6be73c103e (diff) | |
download | sink-4d9746c828558c9f872e0aed52442863affb25d5.tar.gz sink-4d9746c828558c9f872e0aed52442863affb25d5.zip |
Fromatted the whole codebase with clang-format.
clang-format -i */**{.cpp,.h}
Diffstat (limited to 'common/resourcecontrol.cpp')
-rw-r--r-- | common/resourcecontrol.cpp | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/common/resourcecontrol.cpp b/common/resourcecontrol.cpp index 20125ac..d8b0972 100644 --- a/common/resourcecontrol.cpp +++ b/common/resourcecontrol.cpp | |||
@@ -32,28 +32,31 @@ | |||
32 | #undef DEBUG_AREA | 32 | #undef DEBUG_AREA |
33 | #define DEBUG_AREA "client.resourcecontrol" | 33 | #define DEBUG_AREA "client.resourcecontrol" |
34 | 34 | ||
35 | namespace Sink | 35 | namespace Sink { |
36 | { | ||
37 | 36 | ||
38 | KAsync::Job<void> ResourceControl::shutdown(const QByteArray &identifier) | 37 | KAsync::Job<void> ResourceControl::shutdown(const QByteArray &identifier) |
39 | { | 38 | { |
40 | Trace() << "shutdown " << identifier; | 39 | Trace() << "shutdown " << identifier; |
41 | auto time = QSharedPointer<QTime>::create(); | 40 | auto time = QSharedPointer<QTime>::create(); |
42 | time->start(); | 41 | time->start(); |
43 | return ResourceAccess::connectToServer(identifier).then<void, QSharedPointer<QLocalSocket>>([identifier, time](QSharedPointer<QLocalSocket> socket, KAsync::Future<void> &future) { | 42 | return ResourceAccess::connectToServer(identifier) |
44 | //We can't currently reuse the socket | 43 | .then<void, QSharedPointer<QLocalSocket>>( |
45 | socket->close(); | 44 | [identifier, time](QSharedPointer<QLocalSocket> socket, KAsync::Future<void> &future) { |
46 | auto resourceAccess = ResourceAccessFactory::instance().getAccess(identifier); | 45 | // We can't currently reuse the socket |
47 | resourceAccess->open(); | 46 | socket->close(); |
48 | resourceAccess->sendCommand(Sink::Commands::ShutdownCommand).then<void>([&future, resourceAccess, time]() { | 47 | auto resourceAccess = ResourceAccessFactory::instance().getAccess(identifier); |
49 | Trace() << "Shutdown complete." << Log::TraceTime(time->elapsed()); | 48 | resourceAccess->open(); |
50 | future.setFinished(); | 49 | resourceAccess->sendCommand(Sink::Commands::ShutdownCommand) |
51 | }).exec(); | 50 | .then<void>([&future, resourceAccess, time]() { |
52 | }, | 51 | Trace() << "Shutdown complete." << Log::TraceTime(time->elapsed()); |
53 | [](int, const QString &) { | 52 | future.setFinished(); |
54 | Trace() << "Resource is already closed."; | 53 | }) |
55 | //Resource isn't started, nothing to shutdown | 54 | .exec(); |
56 | }); | 55 | }, |
56 | [](int, const QString &) { | ||
57 | Trace() << "Resource is already closed."; | ||
58 | // Resource isn't started, nothing to shutdown | ||
59 | }); | ||
57 | } | 60 | } |
58 | 61 | ||
59 | KAsync::Job<void> ResourceControl::start(const QByteArray &identifier) | 62 | KAsync::Job<void> ResourceControl::start(const QByteArray &identifier) |
@@ -63,23 +66,19 @@ KAsync::Job<void> ResourceControl::start(const QByteArray &identifier) | |||
63 | time->start(); | 66 | time->start(); |
64 | auto resourceAccess = ResourceAccessFactory::instance().getAccess(identifier); | 67 | auto resourceAccess = ResourceAccessFactory::instance().getAccess(identifier); |
65 | resourceAccess->open(); | 68 | resourceAccess->open(); |
66 | return resourceAccess->sendCommand(Sink::Commands::PingCommand).then<void>([resourceAccess, time]() { | 69 | return resourceAccess->sendCommand(Sink::Commands::PingCommand).then<void>([resourceAccess, time]() { Trace() << "Start complete." << Log::TraceTime(time->elapsed()); }); |
67 | Trace() << "Start complete." << Log::TraceTime(time->elapsed()); | ||
68 | }); | ||
69 | } | 70 | } |
70 | 71 | ||
71 | KAsync::Job<void> ResourceControl::flushMessageQueue(const QByteArrayList &resourceIdentifier) | 72 | KAsync::Job<void> ResourceControl::flushMessageQueue(const QByteArrayList &resourceIdentifier) |
72 | { | 73 | { |
73 | Trace() << "flushMessageQueue" << resourceIdentifier; | 74 | Trace() << "flushMessageQueue" << resourceIdentifier; |
74 | return KAsync::iterate(resourceIdentifier) | 75 | return KAsync::iterate(resourceIdentifier) |
75 | .template each<void, QByteArray>([](const QByteArray &resource, KAsync::Future<void> &future) { | 76 | .template each<void, QByteArray>([](const QByteArray &resource, KAsync::Future<void> &future) { |
76 | Trace() << "Flushing message queue " << resource; | 77 | Trace() << "Flushing message queue " << resource; |
77 | auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource); | 78 | auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource); |
78 | resourceAccess->open(); | 79 | resourceAccess->open(); |
79 | resourceAccess->synchronizeResource(false, true).then<void>([&future, resourceAccess]() { | 80 | resourceAccess->synchronizeResource(false, true).then<void>([&future, resourceAccess]() { future.setFinished(); }).exec(); |
80 | future.setFinished(); | 81 | }); |
81 | }).exec(); | ||
82 | }); | ||
83 | } | 82 | } |
84 | 83 | ||
85 | KAsync::Job<void> ResourceControl::flushReplayQueue(const QByteArrayList &resourceIdentifier) | 84 | KAsync::Job<void> ResourceControl::flushReplayQueue(const QByteArrayList &resourceIdentifier) |
@@ -114,7 +113,7 @@ KAsync::Job<void> ResourceControl::inspect(const Inspection &inspectionCommand) | |||
114 | }); | 113 | }); |
115 | } | 114 | } |
116 | 115 | ||
117 | #define REGISTER_TYPE(T) template KAsync::Job<void> ResourceControl::inspect<T>(const Inspection &); \ | 116 | #define REGISTER_TYPE(T) template KAsync::Job<void> ResourceControl::inspect<T>(const Inspection &); |
118 | 117 | ||
119 | REGISTER_TYPE(ApplicationDomain::Event); | 118 | REGISTER_TYPE(ApplicationDomain::Event); |
120 | REGISTER_TYPE(ApplicationDomain::Mail); | 119 | REGISTER_TYPE(ApplicationDomain::Mail); |
@@ -122,4 +121,3 @@ REGISTER_TYPE(ApplicationDomain::Folder); | |||
122 | REGISTER_TYPE(ApplicationDomain::SinkResource); | 121 | REGISTER_TYPE(ApplicationDomain::SinkResource); |
123 | 122 | ||
124 | } // namespace Sink | 123 | } // namespace Sink |
125 | |||