* hb_thread_init() ************************************************************************ * name: user-friendly name * function: the thread routine * arg: argument of the routine * priority: HB_LOW_PRIORITY or HB_NORMAL_PRIORITY ***********************************************************************/
| 1024 | * priority: HB_LOW_PRIORITY or HB_NORMAL_PRIORITY |
| 1025 | ***********************************************************************/ |
| 1026 | hb_thread_t * hb_thread_init( const char * name, void (* function)(void *), |
| 1027 | void * arg, int priority ) |
| 1028 | { |
| 1029 | hb_thread_t * t = calloc( sizeof( hb_thread_t ), 1 ); |
| 1030 | |
| 1031 | t->name = strdup( name ); |
| 1032 | t->function = function; |
| 1033 | t->arg = arg; |
| 1034 | t->priority = priority; |
| 1035 | |
| 1036 | t->lock = hb_lock_init(); |
| 1037 | |
| 1038 | /* Create and start the thread */ |
| 1039 | pthread_create( &t->thread, NULL, |
| 1040 | (void * (*)( void * )) hb_thread_func, t ); |
| 1041 | |
| 1042 | hb_deep_log( 2, "thread %"PRIx64" started (\"%s\")", hb_thread_to_integer( t ), t->name ); |
| 1043 | return t; |
| 1044 | } |
| 1045 | |
| 1046 | /************************************************************************ |
| 1047 | * hb_thread_close() |
no test coverage detected