blob: 0d4a00783377d0791aaad09c06e2f55c1437054e [file] [log] [blame]
Timur Iskhakov16a04372017-07-07 13:28:56 -07001#ifndef ANDROID_HARDWARE_TESTS_MULTITHREAD_V1_0_MULTITHREAD_H
2#define ANDROID_HARDWARE_TESTS_MULTITHREAD_V1_0_MULTITHREAD_H
3
4#include <android/hardware/tests/multithread/1.0/IMultithread.h>
5#include <hidl/Status.h>
6
7#include <chrono>
8#include <condition_variable>
9#include <mutex>
10
11namespace android {
12namespace hardware {
13namespace tests {
14namespace multithread {
15namespace V1_0 {
16namespace implementation {
17
18using ::android::hardware::tests::multithread::V1_0::IMultithread;
19using ::android::hardware::Return;
20using ::android::hardware::Void;
21
22using namespace std::chrono_literals;
23
24struct Multithread : public IMultithread {
25 // Methods from ::android::hardware::tests::multithread::V1_0::IMultithread follow.
26 virtual Return<void> setNumThreads(int32_t maxThreads, int32_t numThreads) override;
27 virtual Return<bool> runNewThread() override;
28
29 private:
30 int32_t mNumThreads;
31 bool mNoTimeout;
32
33 std::condition_variable mCv;
34 std::mutex mCvMutex;
35
36 static constexpr auto kTimeoutDuration = 100ms;
37};
38
39extern "C" IMultithread* HIDL_FETCH_IMultithread(const char* name);
40
41} // namespace implementation
42} // namespace V1_0
43} // namespace multithread
44} // namespace tests
45} // namespace hardware
46} // namespace android
47
48#endif // ANDROID_HARDWARE_TESTS_MULTITHREAD_V1_0_MULTITHREAD_H