void DeviceDescriptor::Close() { assert(InMainThread()); assert(!IsBorrowed()); CancelAsync(); #ifdef HAVE_INTERNAL_GPS delete internal_sensors; internal_sensors = nullptr; #endif #ifdef ANDROID delete droidsoar_v2; droidsoar_v2 = nullptr; for (unsigned i=0; i<sizeof i2cbaro/sizeof i2cbaro[0]; i++) { delete i2cbaro[i]; i2cbaro[i] = nullptr; } delete nunchuck; nunchuck = nullptr; delete voltage; voltage = nullptr; #endif /* safely delete the Device object */ Device *old_device = device; { const ScopeLock protect(mutex); device = nullptr; /* after leaving this scope, no other thread may use the old object; to avoid locking the mutex for too long, the "delete" is called after the scope */ } delete old_device; delete second_device; second_device = nullptr; Port *old_port = port; port = nullptr; delete old_port; ticker = false; { const ScopeLock lock(device_blackboard->mutex); device_blackboard->SetRealState(index).Reset(); device_blackboard->ScheduleMerge(); } settings_sent.Clear(); settings_received.Clear(); }
void DeviceDescriptor::Open(OperationEnvironment &env) { assert(InMainThread()); assert(port == nullptr); assert(device == nullptr); assert(!ticker); assert(!IsBorrowed()); if (is_simulator() || !config.IsAvailable()) return; CancelAsync(); assert(!IsOccupied()); assert(open_job == nullptr); TCHAR buffer[64]; LogFormat(_T("Opening device %s"), config.GetPortName(buffer, 64)); open_job = new OpenDeviceJob(*this); async.Start(open_job, env, this); }
InterprocessServer::~InterprocessServer() { CancelAsync(); Join(); }
WorkerManager::~WorkerManager() { CancelAsync(); }