@@ -242,41 +242,47 @@ struct EdgeConstraints
242
242
243
243
std::future<std::shared_ptr<object::AppointmentConnection>> Query::getAppointments (service::RequestId requestId, std::unique_ptr<int >&& first, std::unique_ptr<rapidjson::Value>&& after, std::unique_ptr<int >&& last, std::unique_ptr<rapidjson::Value>&& before) const
244
244
{
245
- loadAppointments ();
246
-
247
- std::promise< std::shared_ptr<object::AppointmentConnection>> promise;
248
- EdgeConstraints<Appointment, AppointmentConnection> constraints (requestId, _appointments);
249
- auto connection = constraints (first. get (), after. get (), last. get (), before. get () );
245
+ auto spThis = shared_from_this ();
246
+ return std::async (std::launch::async,
247
+ [ this , spThis](service::RequestId requestIdWrapped, std::unique_ptr< int >&& firstWrapped, std::unique_ptr<rapidjson::Value>&& afterWrapped, std::unique_ptr< int >&& lastWrapped, std::unique_ptr<rapidjson::Value>&& beforeWrapped)
248
+ {
249
+ loadAppointments ( );
250
250
251
- promise.set_value (std::static_pointer_cast<object::AppointmentConnection>(connection));
251
+ EdgeConstraints<Appointment, AppointmentConnection> constraints (requestIdWrapped, _appointments);
252
+ auto connection = constraints (firstWrapped.get (), afterWrapped.get (), lastWrapped.get (), beforeWrapped.get ());
252
253
253
- return promise.get_future ();
254
+ return std::static_pointer_cast<object::AppointmentConnection>(connection);
255
+ }, requestId, std::move (first), std::move (after), std::move (last), std::move (before));
254
256
}
255
257
256
258
std::future<std::shared_ptr<object::TaskConnection>> Query::getTasks (service::RequestId requestId, std::unique_ptr<int >&& first, std::unique_ptr<rapidjson::Value>&& after, std::unique_ptr<int >&& last, std::unique_ptr<rapidjson::Value>&& before) const
257
259
{
258
- loadTasks ();
259
-
260
- std::promise< std::shared_ptr<object::TaskConnection>> promise;
261
- EdgeConstraints<Task, TaskConnection> constraints (requestId, _tasks);
262
- auto connection = constraints (first. get (), after. get (), last. get (), before. get () );
260
+ auto spThis = shared_from_this ();
261
+ return std::async (std::launch::async,
262
+ [ this , spThis](service::RequestId requestIdWrapped, std::unique_ptr< int >&& firstWrapped, std::unique_ptr<rapidjson::Value>&& afterWrapped, std::unique_ptr< int >&& lastWrapped, std::unique_ptr<rapidjson::Value>&& beforeWrapped)
263
+ {
264
+ loadTasks ( );
263
265
264
- promise.set_value (std::static_pointer_cast<object::TaskConnection>(connection));
266
+ EdgeConstraints<Task, TaskConnection> constraints (requestIdWrapped, _tasks);
267
+ auto connection = constraints (firstWrapped.get (), afterWrapped.get (), lastWrapped.get (), beforeWrapped.get ());
265
268
266
- return promise.get_future ();
269
+ return std::static_pointer_cast<object::TaskConnection>(connection);
270
+ }, requestId, std::move (first), std::move (after), std::move (last), std::move (before));
267
271
}
268
272
269
273
std::future<std::shared_ptr<object::FolderConnection>> Query::getUnreadCounts (service::RequestId requestId, std::unique_ptr<int >&& first, std::unique_ptr<rapidjson::Value>&& after, std::unique_ptr<int >&& last, std::unique_ptr<rapidjson::Value>&& before) const
270
274
{
271
- loadUnreadCounts ();
272
-
273
- std::promise< std::shared_ptr<object::FolderConnection>> promise;
274
- EdgeConstraints<Folder, FolderConnection> constraints (requestId, _unreadCounts);
275
- auto connection = constraints (first. get (), after. get (), last. get (), before. get () );
275
+ auto spThis = shared_from_this ();
276
+ return std::async (std::launch::async,
277
+ [ this , spThis](service::RequestId requestIdWrapped, std::unique_ptr< int >&& firstWrapped, std::unique_ptr<rapidjson::Value>&& afterWrapped, std::unique_ptr< int >&& lastWrapped, std::unique_ptr<rapidjson::Value>&& beforeWrapped)
278
+ {
279
+ loadUnreadCounts ( );
276
280
277
- promise.set_value (std::static_pointer_cast<object::FolderConnection>(connection));
281
+ EdgeConstraints<Folder, FolderConnection> constraints (requestIdWrapped, _unreadCounts);
282
+ auto connection = constraints (firstWrapped.get (), afterWrapped.get (), lastWrapped.get (), beforeWrapped.get ());
278
283
279
- return promise.get_future ();
284
+ return std::static_pointer_cast<object::FolderConnection>(connection);
285
+ }, requestId, std::move (first), std::move (after), std::move (last), std::move (before));
280
286
}
281
287
282
288
std::future<std::vector<std::shared_ptr<object::Appointment>>> Query::getAppointmentsById (service::RequestId requestId, std::vector<std::vector<uint8_t >>&& ids) const
0 commit comments