mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Introduce scanning sessions
FastPairScanner::ScanningSession and ScannerBroker::ScanningSession separate the lifetime of FastPairScanner/ScannerBroker from the lifetime of scanning sessions. This simplifies the cleanup. PiperOrigin-RevId: 535675988
This commit is contained in:
committed by
Copybara-Service
parent
4596f32499
commit
3adb98a5ff
@@ -34,6 +34,15 @@ class ABSL_LOCKABLE SingleThreadExecutor : public SubmittableExecutor {
|
||||
SingleThreadExecutor& operator=(SingleThreadExecutor&&) = default;
|
||||
};
|
||||
|
||||
// Moves the object to `executor` and destroys it there.
|
||||
// This pattern is useful when there are some tasks running on `executor` that
|
||||
// hold a reference to `object`. The tasks will complete before `object` is
|
||||
// destroyed.
|
||||
template <typename T>
|
||||
void DestroyOnExecutor(T object, SingleThreadExecutor* executor) {
|
||||
executor->Execute([object = std::move(object)] {});
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // PLATFORM_PUBLIC_SINGLE_THREAD_EXECUTOR_H_
|
||||
|
||||
Reference in New Issue
Block a user