• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pj_thread_this函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中pj_thread_this函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_thread_this函数的具体用法?C++ pj_thread_this怎么用?C++ pj_thread_this使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pj_thread_this函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PJ_DEF

/*
 * pj_mutex_trylock()
 */
PJ_DEF(pj_status_t) pj_mutex_trylock(pj_mutex_t *mutex)
{
    pj_status_t status;

    PJ_CHECK_STACK();
    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);

    LOG_MUTEX((mutex->obj_name, "Mutex: thread %s is trying", 
				pj_thread_this()->obj_name));

#if PJ_WIN32_WINNT >= 0x0400
    status=TryEnterCriticalSection(&mutex->crit) ? PJ_SUCCESS : PJ_EUNKNOWN;
#else
    status = WaitForSingleObject(mutex->hMutex, 0)==WAIT_OBJECT_0 ? 
                PJ_SUCCESS : PJ_ETIMEDOUT;
#endif
    if (status==PJ_SUCCESS) {
	LOG_MUTEX((mutex->obj_name, "Mutex acquired by thread %s", 
				  pj_thread_this()->obj_name));

#if PJ_DEBUG
	mutex->owner = pj_thread_this();
	++mutex->nesting_level;
#endif
    } else {
	LOG_MUTEX((mutex->obj_name, "Mutex: thread %s's trylock() failed", 
				    pj_thread_this()->obj_name));
    }

    return status;
}
开发者ID:LuLei2013,项目名称:pjproject,代码行数:34,代码来源:os_core_win32.c


示例2: PJ_DEF

/*
 * pj_thread_join()
 */
PJ_DEF(pj_status_t) pj_thread_join(pj_thread_t *p)
{
#if PJ_HAS_THREADS
    pj_thread_t *rec = (pj_thread_t *)p;
    void *ret;
    int result;

    PJ_CHECK_STACK();
    if(pj_thread_this()->thread == rec->thread){
    	return PJ_SUCCESS;
    }

    PJ_LOG(6, (pj_thread_this()->obj_name, "Joining thread %s", p->obj_name));
    result = pthread_join( rec->thread, &ret);

    if (result == 0)
	return PJ_SUCCESS;
    else {
	/* Calling pthread_join() on a thread that no longer exists and 
	 * getting back ESRCH isn't an error (in this context). 
	 * Thanks Phil Torre <[email protected]>.
	 */
	return result==ESRCH ? PJ_SUCCESS : PJ_RETURN_OS_ERROR(result);
    }
#else
    PJ_CHECK_STACK();
    pj_assert(!"No multithreading support!");
    return PJ_EINVALIDOP;
#endif
}
开发者ID:ChrisKwon,项目名称:spore,代码行数:33,代码来源:os_core_unix.c


示例3: pj_sem_wait_for

static pj_status_t pj_sem_wait_for(pj_sem_t *sem, unsigned timeout)
{
    DWORD result;

    PJ_CHECK_STACK();
    PJ_ASSERT_RETURN(sem, PJ_EINVAL);

    LOG_MUTEX((sem->obj_name, "Semaphore: thread %s is waiting", 
			      pj_thread_this()->obj_name));

    result = WaitForSingleObject(sem->hSemaphore, timeout);
    if (result == WAIT_OBJECT_0) {
	LOG_MUTEX((sem->obj_name, "Semaphore acquired by thread %s", 
				  pj_thread_this()->obj_name));
    } else {
	LOG_MUTEX((sem->obj_name, "Semaphore: thread %s FAILED to acquire", 
				  pj_thread_this()->obj_name));
    }

    if (result==WAIT_OBJECT_0)
        return PJ_SUCCESS;
    else if (result==WAIT_TIMEOUT)
        return PJ_ETIMEDOUT;
    else
        return PJ_RETURN_OS_ERROR(GetLastError());
}
开发者ID:LuLei2013,项目名称:pjproject,代码行数:26,代码来源:os_core_win32.c


示例4: PJ_DEF

/*
 * pj_sem_wait()
 */
PJ_DEF(pj_status_t) pj_sem_wait(pj_sem_t *sem)
{
#if PJ_HAS_THREADS
    int result;

    PJ_CHECK_STACK();
    PJ_ASSERT_RETURN(sem, PJ_EINVAL);

    PJ_LOG(6, (sem->obj_name, "Semaphore: thread %s is waiting", 
			      pj_thread_this(sem->inst_id)->obj_name));

#if defined(PJ_DARWINOS) && PJ_DARWINOS!=0
	result = dispatch_semaphore_wait(sem->sem, DISPATCH_TIME_FOREVER );
#else
    result = sem_wait( sem->sem);
    
#endif
    if (result == 0) {
	PJ_LOG(6, (sem->obj_name, "Semaphore acquired by thread %s", 
				  pj_thread_this(sem->inst_id)->obj_name));
    } else {
	PJ_LOG(6, (sem->obj_name, "Semaphore: thread %s FAILED to acquire", 
				  pj_thread_this(sem->inst_id)->obj_name));
    }

    if (result == 0)
	return PJ_SUCCESS;
    else
	return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
#else
    pj_assert( sem == (pj_sem_t*) 1 );
    return PJ_SUCCESS;
#endif
}
开发者ID:Antares84,项目名称:asuswrt-merlin,代码行数:37,代码来源:os_core_unix.c


示例5: pj_event_wait_for

static pj_status_t pj_event_wait_for(pj_event_t *event, unsigned timeout)
{
    DWORD result;

    PJ_CHECK_STACK();
    PJ_ASSERT_RETURN(event, PJ_EINVAL);

    PJ_LOG(6, (event->obj_name, "Event: thread %s is waiting", 
			        pj_thread_this()->obj_name));

    result = WaitForSingleObject(event->hEvent, timeout);
    if (result == WAIT_OBJECT_0) {
	PJ_LOG(6, (event->obj_name, "Event: thread %s is released", 
				    pj_thread_this()->obj_name));
    } else {
	PJ_LOG(6, (event->obj_name, "Event: thread %s FAILED to acquire", 
				    pj_thread_this()->obj_name));
    }

    if (result==WAIT_OBJECT_0)
        return PJ_SUCCESS;
    else if (result==WAIT_TIMEOUT)
        return PJ_ETIMEDOUT;
    else
        return PJ_RETURN_OS_ERROR(GetLastError());
}
开发者ID:LuLei2013,项目名称:pjproject,代码行数:26,代码来源:os_core_win32.c


示例6: PJ_DEF

/*
 * pj_thread_join()
 */
PJ_DEF(pj_status_t) pj_thread_join(pj_thread_t *p)
{
    pj_thread_t *rec = (pj_thread_t *)p;
    DWORD rc;

    PJ_CHECK_STACK();
    PJ_ASSERT_RETURN(p, PJ_EINVAL);

    if (p == pj_thread_this())
	return PJ_ECANCELLED;

    PJ_LOG(6, (pj_thread_this()->obj_name, "Joining thread %s", p->obj_name));

#if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8
    rc = WaitForSingleObjectEx(rec->hthread, INFINITE, FALSE);
#else
    rc = WaitForSingleObject(rec->hthread, INFINITE);
#endif    

    if (rc==WAIT_OBJECT_0)
        return PJ_SUCCESS;
    else if (rc==WAIT_TIMEOUT)
        return PJ_ETIMEDOUT;
    else
        return PJ_RETURN_OS_ERROR(GetLastError());
}
开发者ID:asterisk,项目名称:pjproject,代码行数:29,代码来源:os_core_win32.c


示例7: clock_thread

/*
 * Clock thread
 */
static int clock_thread(void *arg)
{
    pj_timestamp now;
    pjmedia_clock *clock = (pjmedia_clock*) arg;

    /* Set thread priority to maximum unless not wanted. */
    if ((clock->options & PJMEDIA_CLOCK_NO_HIGHEST_PRIO) == 0) {
	int max = pj_thread_get_prio_max(pj_thread_this());
	if (max > 0)
	    pj_thread_set_prio(pj_thread_this(), max);
    }

    //printf("%s:------------11--------------\n", THIS_FILE);
    /* Get the first tick */
    pj_get_timestamp(&clock->next_tick);
    clock->next_tick.u64 += clock->interval.u64;


    while (!clock->quitting) {

	pj_get_timestamp(&now);

	/* Wait for the next tick to happen */
	if (now.u64 < clock->next_tick.u64) {
	    unsigned msec;
	    msec = pj_elapsed_msec(&now, &clock->next_tick);
	    pj_thread_sleep(msec);
	}
    //printf("%s:------------12--------------, 0x%02x, %d\n", THIS_FILE, clock, (int)(clock->quitting));
	/* Skip if not running */
	if (!clock->running) {
	    /* Calculate next tick */
	    clock_calc_next_tick(clock, &now);
	    continue;
	}

	pj_lock_acquire(clock->lock);
    //printf("%s:------------13--------------, 0x%02x, %d\n", THIS_FILE, clock, (int)(clock->quitting));
	/* Call callback, if any */
	if (clock->cb)
	    (*clock->cb)(&clock->timestamp, clock->user_data);

	/* Best effort way to detect if we've been destroyed in the callback */
	if (clock->quitting)
	    break;

	/* Increment timestamp */
	clock->timestamp.u64 += clock->timestamp_inc;
    //printf("%s:------------14--------------, 0x%02x, %d\n", THIS_FILE, clock, (int)(clock->quitting));
	/* Calculate next tick */
	clock_calc_next_tick(clock, &now);
    //printf("%s:------------15--------------\n", THIS_FILE);
	pj_lock_release(clock->lock);
    }

    return 0;
}
开发者ID:ashishlal,项目名称:pjproject-2.0.1,代码行数:60,代码来源:clock_thread.c


示例8: alsa_set_max_relative_thread_priority

pj_status_t alsa_set_max_relative_thread_priority(int relative)
{
pj_status_t result;
    struct sched_param param;
    pthread_t* thid;

    thid = (pthread_t*) pj_thread_get_os_handle (pj_thread_this());
#if PJ_LINUX==1
    param.__sched_priority = sched_get_priority_max (SCHED_RR)+relative;
    PJ_LOG (3,(THIS_FILE, "thread(%u): Set thread priority "
          "to %d.",
          (unsigned)syscall (SYS_gettid),(int)param.__sched_priority));
#elif PJ_DARWINOS==1
    param.sched_priority = sched_get_priority_max (SCHED_RR)+relative;
    PJ_LOG (3,(THIS_FILE, "thread(%u): Set thread priority "
   "to %d.",
   (unsigned)syscall (SYS_gettid),(int)param.sched_priority));
#endif
    result = pthread_setschedparam (*thid, SCHED_RR, &param);
    if (result) {
if (result == EPERM)
    PJ_LOG (3,(THIS_FILE, "Unable to increase thread priority, "
  "root access needed."));
else
    PJ_LOG (3,(THIS_FILE, "Unable to increase thread priority, "
  "error: %d",
  result));
    }
    return result;
}
开发者ID:ddv2005,项目名称:intercom,代码行数:30,代码来源:alsa_dev.c


示例9: PJ_DEF

PJ_DEF(pj_bool_t) pj_mutex_is_locked(pj_mutex_t *mutex)
{
    if (mutex->recursive)
	return mutex->owner == pj_thread_this();
    else
	return 1;
}
开发者ID:Jopie64,项目名称:pjsip,代码行数:7,代码来源:os_core_linux_kernel.c


示例10: PJ_DEF

/*
 * pj_mutex_trylock()
 */
PJ_DEF(pj_status_t) pj_mutex_trylock(pj_mutex_t *mutex)
{
  #if PJ_HAS_THREADS
  int status;

  PJ_CHECK_STACK();
  PJ_ASSERT_RETURN(mutex, PJ_EINVAL);

  PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is trying",
    pj_thread_this()->obj_name));

  status = pthread_mutex_trylock( &mutex->mutex );

  if (status==0)
  {
    #if PJ_DEBUG
    mutex->owner = pj_thread_this();
    pj_ansi_strcpy(mutex->owner_name, mutex->owner->obj_name);
    ++mutex->nesting_level;

    PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s (level=%d)",
      pj_thread_this()->obj_name,
      mutex->nesting_level));
    #else
    PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s",
      pj_thread_this()->obj_name));
    #endif
  }
  else
  {
    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s's trylock() failed",
      pj_thread_this()->obj_name));
  }

  if (status==0)
    return PJ_SUCCESS;
  else
    return PJ_RETURN_OS_ERROR(status);
  #else                                           /* PJ_HAS_THREADS */
  pj_assert( mutex == (pj_mutex_t*)1);
  return PJ_SUCCESS;
  #endif
}
开发者ID:mnhorak,项目名称:PJSIP-CMake,代码行数:46,代码来源:os_core_android.c


示例11: pj_mutex_trylock

bool SIPPresence::tryLock()
{
    pj_status_t status;
    status = pj_mutex_trylock(mutex_);
    if (status == PJ_SUCCESS) {
	mutex_owner_ = pj_thread_this();
	++mutex_nesting_level_;
    }
    return status==PJ_SUCCESS;
}
开发者ID:ThereIsNoYeti,项目名称:sflphone,代码行数:10,代码来源:sippresence.cpp


示例12: PJ_DEF

PJ_DEF(pj_status_t) pj_thread_join(pj_thread_t *p)
{
#if PJ_HAS_THREADS
    pj_thread_t *rec = (pj_thread_t *)p;
    void *ret;

    PJ_LOG(6, (pj_thread_this()->obj_name, "Joining thread %s", p->obj_name));
    return pthread_join( rec->thread, &ret);
#else
    PJ_LOG(2, (THIS_FILE, "pj_thread_join() unsupported: thread is not enabled!"));
    return 0;
#endif
}
开发者ID:svn2github,项目名称:pjproject,代码行数:13,代码来源:os_unix.c


示例13: thread_proc

/*
 * The thread's entry point.
 *
 * Each of the thread mainly will just execute the loop which
 * increments a variable.
 */
static void* thread_proc(pj_uint32_t *pcounter)
{
    /* Test that pj_thread_register() works. */
    pj_thread_desc desc;
    pj_thread_t *this_thread;
    unsigned id;
    pj_status_t rc;

    id = *pcounter;
    PJ_UNUSED_ARG(id); /* Warning about unused var if TRACE__ is disabled */
    TRACE__((THIS_FILE, "     thread %d running..", id));

    pj_bzero(desc, sizeof(desc));

    rc = pj_thread_register("thread", desc, &this_thread);
    if (rc != PJ_SUCCESS) {
        app_perror("...error in pj_thread_register", rc);
        return NULL;
    }

    /* Test that pj_thread_this() works */
    this_thread = pj_thread_this();
    if (this_thread == NULL) {
        PJ_LOG(3,(THIS_FILE, "...error: pj_thread_this() returns NULL!"));
        return NULL;
    }

    /* Test that pj_thread_get_name() works */
    if (pj_thread_get_name(this_thread) == NULL) {
        PJ_LOG(3,(THIS_FILE, "...error: pj_thread_get_name() returns NULL!"));
        return NULL;
    }

    /* Main loop */
    for (;!quit_flag;) {
	(*pcounter)++;
        //Must sleep if platform doesn't do time-slicing.
	//pj_thread_sleep(0);
    }

    TRACE__((THIS_FILE, "     thread %d quitting..", id));
    return NULL;
}
开发者ID:avble,项目名称:natClientEx,代码行数:49,代码来源:thread.c



注:本文中的pj_thread_this函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pj_timer_heap_create函数代码示例发布时间:2022-05-30
下一篇:
C++ pj_thread_sleep函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap