scouting: Allow background tasks to cancel themselves

I have a use case where I want a background task to run until it
succeeds. Once it succeeds, it should stop. This patch lets me do that
by adding a `StopFromWithinTask()` function.

Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I06a504a9528d1b88937abcec5688021d621ff921
diff --git a/scouting/background_task/background_task.go b/scouting/background_task/background_task.go
index 6980042..3d7d29a 100644
--- a/scouting/background_task/background_task.go
+++ b/scouting/background_task/background_task.go
@@ -43,6 +43,12 @@
 	}()
 }
 
+// Stops the background task from within the background task. The Stop()
+// function still needs to be called from outside the task.
+func (task *backgroundTask) StopFromWithinTask() {
+	task.stopRequested <- true
+}
+
 func (task *backgroundTask) Stop() {
 	task.stopRequested <- true
 	task.ticker.Stop()