mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Signed-off-by: Alexey Polyudov <apolyudov@google.com> Change-Id: Ia0cddfc8cf46c66d5739bdb45ab7825422912082
28 lines
936 B
C++
28 lines
936 B
C++
#ifndef PLATFORM_V2_PUBLIC_SINGLE_THREAD_EXECUTOR_H_
|
|
#define PLATFORM_V2_PUBLIC_SINGLE_THREAD_EXECUTOR_H_
|
|
|
|
#include "platform_v2/public/submittable_executor.h"
|
|
|
|
namespace location {
|
|
namespace nearby {
|
|
|
|
// An Executor that uses a single worker thread operating off an unbounded
|
|
// queue.
|
|
//
|
|
// https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newSingleThreadExecutor--
|
|
class SingleThreadExecutor final : public SubmittableExecutor {
|
|
public:
|
|
using Platform = api::ImplementationPlatform;
|
|
SingleThreadExecutor()
|
|
: SubmittableExecutor(Platform::CreateSingleThreadExecutor()) {}
|
|
~SingleThreadExecutor() override = default;
|
|
SingleThreadExecutor(SingleThreadExecutor&&) = default;
|
|
SingleThreadExecutor& operator=(SingleThreadExecutor&&) = default;
|
|
int Tid() const { return GetTid(0); }
|
|
};
|
|
|
|
} // namespace nearby
|
|
} // namespace location
|
|
|
|
#endif // PLATFORM_V2_PUBLIC_SINGLE_THREAD_EXECUTOR_H_
|