Skip to content

Commit

Permalink
-- name all created threads
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavriloaie Eugen-Andrei committed Feb 17, 2018
1 parent 7d0ff22 commit 33be039
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions common/osdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ static ALWAYS_INLINE int x264_pthread_fetch_and_add( int *val, int add, x264_pth
#endif
}

static ALWAYS_INLINE void x264_pthread_setname( const char *pName ) {
if (pName == NULL)
return;
#if defined(__APPLE__) && defined(__MACH__)
pthread_setname_np(pName);
#elif defined __linux__
prctl(PR_SET_NAME, pName);
#endif
}

#define WORD_SIZE sizeof(void*)

#define asm __asm__
Expand Down
1 change: 1 addition & 0 deletions common/threadpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct x264_threadpool_t

static void *threadpool_thread( x264_threadpool_t *pool )
{
x264_pthread_setname("x264 TP worker");
if( pool->init_func )
pool->init_func( pool->init_arg );

Expand Down
1 change: 1 addition & 0 deletions common/win32thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static x264_pthread_mutex_t static_mutex;
/* _beginthreadex requires that the start routine is __stdcall */
static unsigned __stdcall win32thread_worker( void *arg )
{
x264_pthread_setname("x264 worker");
x264_pthread_t *h = arg;
*h->p_ret = h->func( h->arg );
return 0;
Expand Down
1 change: 1 addition & 0 deletions encoder/lookahead.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ static void lookahead_slicetype_decide( x264_t *h )

static void *lookahead_thread( x264_t *h )
{
x264_pthread_setname("x264 LA worker");
while( !h->lookahead->b_exit_thread )
{
x264_pthread_mutex_lock( &h->lookahead->ifbuf.mutex );
Expand Down

0 comments on commit 33be039

Please sign in to comment.