Пример #1
0
void dnx_rmlock_uninit(dnx_rmlock_t *lock)
{
  DNX_ASSERT(NULL != lock);

  if (TRUE == lock->event_initialized)
    dnx_event_uninit(&lock->event);
}
Пример #2
0
dnx_status_t dnx_event_init(dnx_event_t *event)
{
  dnx_status_t rc = DNX_ERR_OK;

  DNX_ASSERT(NULL != event);

  event->wait_flag = 0;
  init_waitqueue_head(&event->wait_queue);

  if (DNX_ERR_OK != rc && NULL != event)
    dnx_event_uninit(event);

  return rc;
}
Пример #3
0
void dnx_thread_exit(dnx_thread_t *thread)
{ 
  dnx_status_t rc = DNX_ERR_OK;
  DNX_ASSERT(NULL != thread);
  DNX_ASSERT(FALSE == thread->should_exit);

  thread->should_exit = TRUE;

  rc = dnx_event_wait(&thread->event, DNX_WAIT_FOREVER);

  DNX_ASSERT(DNX_ERR_OK == rc);

  dnx_event_uninit(&thread->event);
}
Пример #4
0
dnx_status_t dnx_thread_create(dnx_thread_t *thread, dnx_thread_cb_t cb,
  void *ctx)
{
  dnx_status_t rc = DNX_ERR_OK;
  int os_rc = 0;

  DNX_ASSERT(NULL != thread);
  DNX_ASSERT(NULL != cb);

  thread->cb = cb;
  thread->ctx =ctx;
  thread->event_initialized = FALSE;

  rc = dnx_event_init(&thread->event); 
  if (DNX_ERR_OK != rc)
  {
    dnx_log_e("Failed to initialize event object\n");
    goto Exit;
  }

  thread->event_initialized = TRUE;
  thread->kthread = kthread_run(dnx_thread_run, thread,
    "dnx_tread");

  if (NULL == thread->kthread)
    rc = dnx_os_err_to_dnx_err(os_rc);

Exit:
  if (DNX_ERR_OK != rc && NULL != thread)
  {
    if (TRUE == thread->event_initialized)
      dnx_event_uninit(&thread->event);
  }

  return rc;
}