destroy method

void destroy()

Implementation

void destroy() async {
  if (!arThreadReady) {
    return;
  }

  arThreadReady = false;

  // We send a Destroy request and wait for a response before killing the thread
  var reqId = ++_reqId;
  var res = Completer();
  _cbs[reqId] = res;
  var msg = Request(reqId: reqId, method: 'destroy');
  _toDetectorThread.send(msg);

  // Wait for the detector to acknoledge the destory and kill the thread
  await res.future;
  _detectorThread.kill();
}