static int prev_battery_level = 0;
static event_pool events_buf[10];
static int buff_count = 0;
+static pthread_attr_t attr;
static pthread_cond_t fill = PTHREAD_COND_INITIALIZER;
static pthread_cond_t empty = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t battery_lister_mutex = PTHREAD_MUTEX_INITIALIZER;
bt_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, bt_event)) {
+ if (pthread_create(&producer, &attr, event_producer, bt_event)) {
_ERR("Failed to pthread_create.");
return;
}
bt_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, bt_event)) {
+ if (pthread_create(&producer, &attr, event_producer, bt_event)) {
_ERR("Failed to pthread_create.");
return;
}
bt_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, bt_event)) {
+ if (pthread_create(&producer, &attr, event_producer, bt_event)) {
_ERR("Failed to pthread_create.");
return;
}
wifi_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, wifi_event)) {
+ if (pthread_create(&producer, &attr, event_producer, wifi_event)) {
_ERR("Failed to pthread_create.");
return;
}
wifi_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, wifi_event)) {
+ if (pthread_create(&producer, &attr, event_producer, wifi_event)) {
_ERR("Failed to pthread_create.");
return;
}
wifi_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, wifi_event)) {
+ if (pthread_create(&producer, &attr, event_producer, wifi_event)) {
_ERR("Failed to pthread_create.");
return;
}
device_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, device_event)) {
+ if (pthread_create(&producer, &attr, event_producer, device_event)) {
_ERR("Failed to pthread_create.");
return;
}
display_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, display_event)) {
+ if (pthread_create(&producer, &attr, event_producer, display_event)) {
_ERR("Failed to pthread_create.");
return;
}
charging_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, charging_event)) {
+ if (pthread_create(&producer, &attr, event_producer, charging_event)) {
_ERR("Failed to pthread_create.");
return;
}
charging_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, charging_event)) {
+ if (pthread_create(&producer, &attr, event_producer, charging_event)) {
_ERR("Failed to pthread_create.");
return;
}
location_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, location_event)) {
+ if (pthread_create(&producer, &attr, event_producer, location_event)) {
_ERR("Failed to pthread_create.");
return;
}
signal_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, signal_event)) {
+ if (pthread_create(&producer, &attr, event_producer, signal_event)) {
_ERR("Failed to pthread_create.");
return;
}
modem_power_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, modem_power_event)) {
+ if (pthread_create(&producer, &attr, event_producer, modem_power_event)) {
_ERR("Failed to pthread_create.");
return;
}
location_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, location_event)) {
+ if (pthread_create(&producer, &attr, event_producer, location_event)) {
_ERR("Failed to pthread_create.");
return;
}
sleep_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, sleep_event)) {
+ if (pthread_create(&producer, &attr, event_producer, sleep_event)) {
_ERR("Failed to pthread_create.");
return;
}
wakeup_event->app = NULL;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, wakeup_event)) {
+ if (pthread_create(&producer, &attr, event_producer, wakeup_event)) {
_ERR("Failed to pthread_create.");
return;
}
app_event->app = appid;
pthread_t producer;
- if (pthread_create(&producer, NULL, event_producer, app_event)) {
+ if (pthread_create(&producer, &attr, event_producer, app_event)) {
_ERR("Failed to pthread_create.");
return;
}
ENTER;
pthread_t consumer;
- if (pthread_create(&consumer, NULL, event_consumer, NULL)) {
+ if (pthread_create(&consumer, &attr, event_consumer, NULL)) {
_ERR("Failed to pthread_create.");
return BATTERY_MONITOR_ERROR_NOT_SUPPORTED;
}
return BATTERY_MONITOR_ERROR_OUT_OF_MEMORY;
}
+ /* Initialize pthread attributes */
+ if (pthread_attr_init(&attr) != 0) {
+ _ERR("pthread_attr_init failed");
+ return BATTERY_MONITOR_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
+ _ERR("pthread_attr_setdetachstate failed");
+
/*Initialize DBus*/
if(bm_listener_dbus_init())
_ERR("bm_listener_dbus_init failed \n");
if(bm_listener_dbus_deinit())
_ERR("failed to de-init dbus ");
+ /* de-initialize pthread attributes */
+ if (pthread_attr_destroy(&attr) != 0)
+ _ERR("pthread_attr_destroy failed");
+
g_hash_table_destroy(app_list);
if (data_obj)