threading: use qemu_thread_XXX abstraction instead of pthread native functions 25/20925/1
authorGeunhae LEE <geunhae.lee@samsung.com>
Wed, 14 May 2014 04:45:14 +0000 (13:45 +0900)
committerGeunhae LEE <geunhae.lee@samsung.com>
Wed, 14 May 2014 04:46:25 +0000 (13:46 +0900)
Change-Id: Id8853d22d29eab4b7c91555e9465455282df93a1
Signed-off-by: Geunhae LEE <geunhae.lee@samsung.com>
tizen/src/emulator.c
tizen/src/guest_server.c
tizen/src/guest_server.h
tizen/src/skin/maruskin_client.c
tizen/src/skin/maruskin_operation.c
tizen/src/skin/maruskin_server.c

index c0da055..1781655 100644 (file)
@@ -500,16 +500,10 @@ static void* main_thread(void* args)
 int main(int argc, char *argv[])
 {
     char** args;
-    pthread_t main_thread_id;
-
+    QemuThread main_thread_id;
     g_argc = argc;
     args = argv;
-
-    if (0 != pthread_create(&main_thread_id, NULL, main_thread, args)) {
-        INFO("Create main thread failed\n");
-        return -1;
-    }
-
+    qemu_thread_create(&main_thread_id, "main_thread", main_thread, (void *)args, QEMU_THREAD_DETACHED);
     ns_event_loop(&thread_running);
 
     return 0;
index 5637a6d..bd7e97b 100644 (file)
@@ -620,20 +620,12 @@ static void* run_guest_server(void* args)
     return NULL;
 }
 
-pthread_t start_guest_server(int server_port)
+void start_guest_server(int server_port)
 {
+    QemuThread thread_id;
     svr_port = server_port;
-
-    pthread_t thread_id;
-
-    if (0 != pthread_create(&thread_id, NULL, run_guest_server, NULL)) {
-        INFO("fail to create guest_server pthread.\n");
-    } else {
-        INFO("created guest server thread\n");
-    }
-
-    return thread_id;
-
+    qemu_thread_create(&thread_id, "guest_server", run_guest_server, NULL, QEMU_THREAD_DETACHED);
+    INFO("created guest server thread\n");
 }
 
 void shutdown_guest_server(void)
index e88b59d..76efd9c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 
+ *
  *
  * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
  *
@@ -34,7 +34,7 @@
 
 #include <pthread.h>
 
-pthread_t start_guest_server( int server_port );
+void start_guest_server( int server_port );
 void shutdown_guest_server( void );
 
 #define STATE_RUNNING 0
index db85ef2..1a236cf 100644 (file)
@@ -343,14 +343,8 @@ int start_skin_client(int argc, char* argv[])
 
     skin_argc = argc;
     skin_argv = argv;
-
-    pthread_t thread_id;
-
-    if (0 != pthread_create(&thread_id, NULL, run_skin_client, NULL)) {
-        ERR("fail to create skin_client pthread\n");
-        return -1;
-    }
-
+    QemuThread thread_id;
+    qemu_thread_create(&thread_id, "skin_client", run_skin_client, NULL, QEMU_THREAD_DETACHED);
     return 1;
 }
 
index b66c3db..4f0a821 100644 (file)
@@ -607,15 +607,9 @@ void shutdown_qemu_gracefully(void)
         requested_shutdown_qemu_gracefully = 1;
 
         INFO("shutdown_qemu_gracefully was called\n");
-
-        pthread_t thread_id;
-        if (0 > pthread_create(
-            &thread_id, NULL, run_timed_shutdown_thread, NULL)) {
-
-            ERR("!!! Fail to create run_timed_shutdown_thread. \
-                shutdown qemu right now !!!\n");
-            qemu_system_shutdown_request();
-        }
+        QemuThread thread_id;
+        qemu_thread_create(&thread_id, "shutdown_thread", run_timed_shutdown_thread,
+                           NULL, QEMU_THREAD_DETACHED);
     } else {
         INFO("shutdown_qemu_gracefully was called twice\n");
         qemu_system_shutdown_request();
index 7a7cae3..e329d6b 100644 (file)
@@ -143,7 +143,6 @@ static int is_force_close_client = 0;
 static int is_started_heartbeat = 0;
 static int stop_heartbeat = 0;
 static int recv_heartbeat_count = 0;
-static pthread_t thread_id_heartbeat;
 
 /* 0: not drawing, 1: drawing */
 int draw_display_state = 0;
@@ -198,7 +197,7 @@ int start_skin_server(int argc, char** argv,
     QemuThread qemu_thread;
 
     qemu_thread_create(&qemu_thread, "skin-server", run_skin_server,
-        NULL, QEMU_THREAD_JOINABLE);
+        NULL, QEMU_THREAD_DETACHED);
 
     return 1;
 }
@@ -1448,12 +1447,9 @@ static int start_heart_beat(void)
     if (ignore_heartbeat) {
         return 1;
     } else {
-        if (0 != pthread_create(&thread_id_heartbeat, NULL, do_heart_beat, NULL)) {
-            ERR("[HB] fail to create heart beat thread\n");
-            return 0;
-        } else {
-            return 1;
-        }
+       QemuThread thread_id_heartbeat;
+       qemu_thread_create(&thread_id_heartbeat, "skin_heartbeat_thread", do_heart_beat, NULL, QEMU_THREAD_DETACHED);
+       return 1;
     }
 }