Firmware updater: rework cancelling

This commit is contained in:
Vojtech Kral 2018-05-21 15:24:24 +02:00
parent 4f4649d046
commit a43e72f696
10 changed files with 101 additions and 45 deletions

View file

@ -13,7 +13,7 @@ class AvrDude
public:
typedef std::shared_ptr<AvrDude> Ptr;
typedef std::function<void(const char * /* msg */, unsigned /* size */)> MessageFn;
typedef std::function<bool(const char * /* task */, unsigned /* progress */)> ProgressFn;
typedef std::function<void(const char * /* task */, unsigned /* progress */)> ProgressFn;
typedef std::function<void(int /* exit status */)> CompleteFn;
AvrDude();
@ -33,8 +33,7 @@ public:
AvrDude& on_message(MessageFn fn);
// Set progress report callback
// Progress is reported per each task (reading / writing), progress is reported in percents.
// The callback's return value indicates whether to continue flashing (true) or cancel (false).
// Progress is reported per each task (reading / writing) in percents.
AvrDude& on_progress(ProgressFn fn);
// Called when avrdude's main function finishes
@ -42,6 +41,8 @@ public:
int run_sync();
Ptr run();
void cancel();
void join();
private:
struct priv;