mirror of https://github.com/schoebel/mars
copy: allow stopping in parallel
This commit is contained in:
parent
afe2513c21
commit
342e5e40a5
|
@ -723,7 +723,7 @@ int _run_copy(struct copy_brick *brick)
|
||||||
static
|
static
|
||||||
bool _is_done(struct copy_brick *brick)
|
bool _is_done(struct copy_brick *brick)
|
||||||
{
|
{
|
||||||
if (brick_thread_should_stop())
|
if (!brick->power.led_on || brick_thread_should_stop())
|
||||||
brick->is_aborting = true;
|
brick->is_aborting = true;
|
||||||
return brick->is_aborting &&
|
return brick->is_aborting &&
|
||||||
atomic_read(&brick->copy_read_flight) + atomic_read(&brick->copy_write_flight) <= 0;
|
atomic_read(&brick->copy_read_flight) + atomic_read(&brick->copy_write_flight) <= 0;
|
||||||
|
@ -742,7 +742,6 @@ static int _copy_thread(void *data)
|
||||||
|
|
||||||
_update_percent(brick, true);
|
_update_percent(brick, true);
|
||||||
|
|
||||||
mars_power_led_on((void*)brick, true);
|
|
||||||
brick->trigger = true;
|
brick->trigger = true;
|
||||||
|
|
||||||
while (!_is_done(brick)) {
|
while (!_is_done(brick)) {
|
||||||
|
@ -848,6 +847,7 @@ static int copy_switch(struct copy_brick *brick)
|
||||||
if (brick->power.led_on)
|
if (brick->power.led_on)
|
||||||
goto done;
|
goto done;
|
||||||
mars_power_led_off((void*)brick, false);
|
mars_power_led_off((void*)brick, false);
|
||||||
|
mars_power_led_on((void*)brick, true);
|
||||||
brick->is_aborting = false;
|
brick->is_aborting = false;
|
||||||
if (!brick->thread) {
|
if (!brick->thread) {
|
||||||
brick->copy_last = brick->copy_start;
|
brick->copy_last = brick->copy_start;
|
||||||
|
@ -861,14 +861,15 @@ static int copy_switch(struct copy_brick *brick)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (brick->power.led_off)
|
/* Tell thread to stop asynchronously */
|
||||||
goto done;
|
|
||||||
mars_power_led_on((void*)brick, false);
|
mars_power_led_on((void*)brick, false);
|
||||||
if (brick->thread) {
|
if (brick->thread) {
|
||||||
|
/* Notice: this will be reported by the thread */
|
||||||
|
if (brick->power.led_off)
|
||||||
|
goto done;
|
||||||
MARS_INF("stopping thread...\n");
|
MARS_INF("stopping thread...\n");
|
||||||
brick_thread_stop(brick->thread);
|
brick_thread_stop(brick->thread);
|
||||||
}
|
}
|
||||||
mars_power_led_off((void *)brick, true);
|
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue