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
Loading
Please register or sign in to comment