From 5153d56321e20974d29c0649839d96e8351775b6 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Sun, 20 Jun 2010 14:31:24 -0700 Subject: [PATCH] loc_api: Use create_thread_cb for all threads that call back into the framework. Change-Id: I07c2d5664d3f1a167af56ddd76b60393de170931 Signed-off-by: Mike Lockwood --- loc_api/libloc_api/loc_eng.cpp | 17 ++++++++--------- loc_api/libloc_api/loc_eng_ni.cpp | 27 ++------------------------- loc_api/libloc_api/loc_eng_ni.h | 1 - 3 files changed, 10 insertions(+), 35 deletions(-) diff --git a/loc_api/libloc_api/loc_eng.cpp b/loc_api/libloc_api/loc_eng.cpp index 87c26f49..fa0a598b 100755 --- a/loc_api/libloc_api/loc_eng.cpp +++ b/loc_api/libloc_api/loc_eng.cpp @@ -91,7 +91,7 @@ static void loc_eng_report_status (const rpc_loc_status_event_s_type *status_rep static void loc_eng_report_nmea (const rpc_loc_nmea_report_s_type *nmea_report_ptr); static void loc_eng_process_conn_request (const rpc_loc_server_request_s_type *server_request_ptr); -static void* loc_eng_process_deferred_action (void* arg); +static void loc_eng_process_deferred_action (void* arg); static void loc_eng_process_atl_deferred_action (int flags); static void loc_eng_delete_aiding_data_deferred_action (void); @@ -227,10 +227,8 @@ static int loc_eng_init(GpsCallbacks* callbacks) pthread_cond_init(&loc_eng_data.ioctl_data.cb_arrived_cond, NULL); loc_eng_data.deferred_action_thread = NULL; - pthread_create (&(loc_eng_data.deferred_action_thread), - NULL, - loc_eng_process_deferred_action, - NULL); + loc_eng_data.deferred_action_thread = callbacks->create_thread_cb("loc_api", + loc_eng_process_deferred_action, NULL); LOGD ("loc_eng_init called, client id = %d\n", (int32) loc_eng_data.client_handle); return 0; @@ -937,13 +935,13 @@ static void loc_eng_report_status (const rpc_loc_status_event_s_type *status_rep { // GPS_STATUS_SESSION_BEGIN implies GPS_STATUS_ENGINE_ON status.status = GPS_STATUS_SESSION_BEGIN; - loc_eng_data.status_cb (&status); + loc_eng_data.status_cb(&status); } else if (status_report_ptr->payload.rpc_loc_status_event_payload_u_type_u.engine_state == RPC_LOC_ENGINE_STATE_OFF) { // GPS_STATUS_SESSION_END implies GPS_STATUS_ENGINE_OFF status.status = GPS_STATUS_ENGINE_OFF; - loc_eng_data.status_cb (&status); + loc_eng_data.status_cb(&status); } } @@ -1397,7 +1395,7 @@ SIDE EFFECTS N/A ===========================================================================*/ -static void* loc_eng_process_deferred_action (void* arg) +static void loc_eng_process_deferred_action (void* arg) { AGpsStatus status; status.size = sizeof(status); @@ -1480,7 +1478,8 @@ static void* loc_eng_process_deferred_action (void* arg) LOGD("loc_eng_process_deferred_action thread exiting\n"); loc_eng_data.release_wakelock_cb(); - return NULL; + + loc_eng_data.deferred_action_thread = 0; } // for gps.c diff --git a/loc_api/libloc_api/loc_eng_ni.cpp b/loc_api/libloc_api/loc_eng_ni.cpp index fec86b6e..958103a1 100755 --- a/loc_api/libloc_api/loc_eng_ni.cpp +++ b/loc_api/libloc_api/loc_eng_ni.cpp @@ -520,7 +520,7 @@ int loc_eng_ni_callback ( FUNCTION loc_ni_thread_proc ===========================================================================*/ -static void* loc_ni_thread_proc(void *threadid) +static void loc_ni_thread_proc(void *unused) { LOGI("Starting Loc NI thread...\n"); @@ -543,29 +543,6 @@ static void* loc_ni_thread_proc(void *threadid) pthread_mutex_unlock(&loc_eng_ni_data.loc_ni_lock); } /* while (1) */ - - pthread_exit(NULL); - return NULL; -} - -/*=========================================================================== - -FUNCTION loc_ni_thread_start - -===========================================================================*/ -static int loc_ni_thread_start(void) -{ - int rc = 0; - - rc = pthread_create(&loc_eng_ni_data.loc_ni_thread, NULL, loc_ni_thread_proc, NULL); - - if (rc) - { - LOGE("Loc NI thread is not created.\n"); - return -1; - } - - return 0; } /*=========================================================================== @@ -591,7 +568,7 @@ void loc_eng_ni_init(GpsNiCallbacks *callbacks) if (!loc_eng_ni_data_init) { pthread_mutex_init(&loc_eng_ni_data.loc_ni_lock, NULL); - loc_ni_thread_start(); + callbacks->create_thread_cb("loc_api_ni", loc_ni_thread_proc, NULL); loc_eng_ni_data_init = TRUE; } diff --git a/loc_api/libloc_api/loc_eng_ni.h b/loc_api/libloc_api/loc_eng_ni.h index be234054..88d285ae 100755 --- a/loc_api/libloc_api/loc_eng_ni.h +++ b/loc_api/libloc_api/loc_eng_ni.h @@ -36,7 +36,6 @@ $Id: extern const GpsNiInterface sLocEngNiInterface; typedef struct { - pthread_t loc_ni_thread; /* NI thread */ pthread_mutex_t loc_ni_lock; int response_time_left; /* examine time for NI response */ boolean notif_in_progress; /* NI notification/verification in progress */