OSDN Git Service

Add Timer as an alternative to osi alarm
authorHansong Zhang <hsz@google.com>
Tue, 14 Aug 2018 21:29:23 +0000 (14:29 -0700)
committerHansong Zhang <hsz@google.com>
Thu, 13 Sep 2018 20:37:42 +0000 (13:37 -0700)
commit438b08c27d1a2fa9821d9d7f70f3fba9314347c0
treed473997f11e1552369353007ef161dcf6ffdde06
parent58eac7794941c3e517c9cd50e945cb347c78c7a9
Add Timer as an alternative to osi alarm

* Add a private method MessageLoopThread.DoInThreadDelayed to post a
  delayed task in message loop, as an alternative approach to osi alarm
  clock
* Add a unit test for MessageLoopThread to check ShutDown() waits until
  current task finishes
* Add Timer using MessageLoopThread.DoInThreadDelayed
* Timer provides similar API as osi alarm, and uses same OS clock (boot
  timer) as alarm
* Add benchmark and unit tests to ensure the performance is comparable
  to the existing osi alarm

Test: Run unit test and benchmark test
      ./test/run_unit_tests.sh bluetooth_test_common
      ./test/run_benchmarks.sh bluetooth_benchmark_timer_performance
      --benchmark_repetitions=10 --benchmark_report_aggregates_only=true
Bug: 110303473
Change-Id: I6f2e7ae2f80f9889fc5fe3c8cd6b9b2670938b46
common/Android.bp
common/benchmark/timer_performance_benchmark.cc [new file with mode: 0644]
common/message_loop_thread.cc
common/message_loop_thread.h
common/message_loop_thread_unittest.cc
common/timer.cc [new file with mode: 0644]
common/timer.h [new file with mode: 0644]
common/timer_unittest.cc [new file with mode: 0644]
test/run_benchmarks.sh