Fission FSN
Loading...
Searching...
No Matches
fsShareCompletions.h
Go to the documentation of this file.
1/********************************************************************
2*
3* File: fsShareCompletions.h
4*
5* Purpose: Share results can arrive on any thread (Java, WinRT, UIKit);
6* they are queued and handed out from update().
7*
8*********************************************************************/
9
10#ifndef fsShareCompletionshdr
11#define fsShareCompletionshdr
12
14
15#include <mutex>
16#include <utility>
17#include <vector>
18
20{
21public:
22 void push(fsShareSheetService::DoneCallback done, fsShareResult result, std::string detail = std::string())
23 {
24 std::lock_guard<std::mutex> lock(mMutex);
25 mPending.push_back({std::move(done), result, std::move(detail)});
26 }
27
28 void deliver()
29 {
30 std::vector<Pending> pending;
31 {
32 std::lock_guard<std::mutex> lock(mMutex);
33 pending.swap(mPending);
34 }
35 for (auto& item : pending)
36 {
37 if (item.done)
38 {
39 item.done(item.result, item.detail);
40 }
41 }
42 }
43
44private:
45 struct Pending
46 {
48 fsShareResult result;
49 std::string detail;
50 };
51
52 std::mutex mMutex;
53 std::vector<Pending> mPending;
54};
55
56#endif
Definition fsShareCompletions.h:20
void deliver()
Definition fsShareCompletions.h:28
void push(fsShareSheetService::DoneCallback done, fsShareResult result, std::string detail=std::string())
Definition fsShareCompletions.h:22
std::function< void(fsShareResult, const std::string &detail)> DoneCallback
Definition fsShareSheetService.h:22
fsShareResult
Definition fsShareTypes.h:33