botsense/bsProxy/bsProxyThread.c
void ThDestroyThread(BsProxyThCtl_T *pThCtl)
{
  if( pThCtl == NULL )
  {
    return;
  }

  // lock global mutex
  ThGlobalLock();

  // do not destroy the thread since there exists users of this thread
  if( pThCtl->m_uRefCnt > 0 )
  {
    pThCtl->m_uRefCnt--;
  }

  // thread is not being used anymore - destroy
  if( pThCtl->m_uRefCnt == 0 )
  {
    // signal thread of exit state change
    ThSyncExit(pThCtl);

    // wait for thread to terminate
    pthread_join(pThCtl->m_thread, NULL);

    // delete the thread hash entry's control block (including its queue)
    ThHashDelete(pThCtl);
  }

  else
  {
    LOGDIAG1("Service Thread \"%s\" detached (refcnt=%u).",
        pThCtl->m_sDevUri, pThCtl->m_uRefCnt);
  }

  // unlock global mutex
  ThGlobalUnlock();
}
/*!
 * \brief Destroy service thread.
 *
 * The thread's reference count is decremented. If the count is zero, then the
 * thread is actually destroyed with all queued requests deleted. The calling
 * thread is suspended until the target service thread terminates.
 *
 * \par Execution Context:
 * Calling thread.
 *
 * \param pThCtl    Service thread control block.
 */
\brief Destroy service thread.
The thread's reference count is decremented. If the count is zero, then the
thread is actually destroyed with all queued requests deleted. The calling
thread is suspended until the target service thread terminates.

\par Execution Context:
Calling thread.

\param pThCtl    Service thread control block.
\ brief Destroy service thread . The thread ' s reference count is decremented . If the count is zero then the thread is actually destroyed with all queued requests deleted . The calling thread is suspended until the target service thread terminates . \ par Execution Context : Calling thread . \ param pThCtl Service thread control block .
void ThDestroyThread(BsProxyThCtl_T *pThCtl)
{
  if( pThCtl == NULL )
  {
    return;
  }
  ThGlobalLock();
  if( pThCtl->m_uRefCnt > 0 )
  {
    pThCtl->m_uRefCnt--;
  }
  if( pThCtl->m_uRefCnt == 0 )
  {
    ThSyncExit(pThCtl);
    pthread_join(pThCtl->m_thread, NULL);
    ThHashDelete(pThCtl);
  }
  else
  {
    LOGDIAG1("Service Thread \"%s\" detached (refcnt=%u).",
        pThCtl->m_sDevUri, pThCtl->m_uRefCnt);
  }
  ThGlobalUnlock();
}
void ThDestroyThread ( BsProxyThCtl_T * pThCtl ) { if ( pThCtl == NULL ) { return ; } ThGlobalLock ( ) ; if ( pThCtl -> m_uRefCnt > 0 ) { pThCtl -> m_uRefCnt -- ; } if ( pThCtl -> m_uRefCnt == 0 ) { ThSyncExit ( pThCtl ) ; pthread_join ( pThCtl -> m_thread , NULL ) ; ThHashDelete ( pThCtl ) ; } else { LOGDIAG1 ( " \" \" " , pThCtl -> m_sDevUri , pThCtl -> m_uRefCnt ) ; } ThGlobalUnlock ( ) ; }
\brief Destroy service thread.
\ brief Destroy service thread .
// lock global mutex // do not destroy the thread since there exists users of this thread // thread is not being used anymore - destroy // signal thread of exit state change // wait for thread to terminate // delete the thread hash entry's control block (including its queue) // unlock global mutex