OSDN Git Service

Use MessageLoop in bt_jni_workqueue thread
authorJakub Pawlowski <jpawlowski@google.com>
Sat, 30 Apr 2016 21:37:40 +0000 (14:37 -0700)
committerJakub Pawlowski <jpawlowski@google.com>
Wed, 11 May 2016 22:38:57 +0000 (15:38 -0700)
commit140645f6b8d87464c08f082bd14740eecab23f71
treea9e27bc69e6cd47e4adebd520e831a6cc67de13a
parent29e794418452c8b35c2d42fe0cda81acd86bbf43
Use MessageLoop in bt_jni_workqueue thread

Up till now, to execute anyting on bt_jni_workqueue thread, we were
sending events to workqueue associated with this thread. Flow was:
btif_transfer_context -> btif_sendmsg -> thread_post.
Events were containing defined action, i.e. BTIF_GATTC_SCAN_START and
pointer to struct that contained all required data to execute it.
This was very cumbersome - figuring out what is executed when event is
send was hard. Also everything have to be packed into structure which
means that
we have to define lots of structures, or have one big super-structure
holding data for all events (like in btif_gatt_client.cc). Event sending
and receiving
logic is a huge percent of all code.

From now on, there will be a MessageLoop running inside bt_jni_workqueue
that will execute all tasks that will be posted with PostTask. The
benefit of having PostTask method, is that we can simply create Closure
that will be run in bt_jni_workqueue thread. It will take care of
transferring all associated values, and their cleanup. It will also do
compile-time check of all parameters. We no longer have to create
events, structs, and separate call logic from execution logic.

Bug: 28485365
Change-Id: I5014ef680757c0d3c6c69781aadc5139c8e1c3c4
btif/Android.mk
btif/BUILD.gn
btif/src/btif_core.cc
btif/src/btif_gatt_client.cc