我要评分
获取效率
正确性
完整性
易理解

HTL_thread_revive

Wakes up a terminated thread.

Interface Definition

int HTL_thread_revive(HTL_thread_pool_t thread_pool, void* (*thread_func)(void *), void *arg, HTL_thread_t *thread);

Description

HTL_thread_revive() is used to wake up a terminated thread and use the new execution function thread_func() and its parameter arg to restore the thread. This function does not change the thread attribute. The restored thread is pushed to the thread pool thread_pool.

Although the HTL_thread pointer is used to transfer the thread handle parameter, the thread handle is not updated. thread must be a terminated thread that has not been released. Threads blocked by other calls may not be restored.

Parameters

Parameter

Type

Description

Input/Output

thread_pool

HTL_thread_pool_t *

Handle to the thread pool.

Input

thread_func

void* (*thread_func)(void *)

New ULT execution function.

Input

arg

void *

Input parameter of thread_func.

Input

thread

HTL_thread_t *

Handle to the ULT.

Input/Output

Return Value

  • HTL_THREAD_SUCCESS: success.
  • Other values: failure. For details, see the error code descriptions.

Example

   /* Create ULTs */
    for (i = 0; i < num_threads; i++) {
        ret = HLT_thread_create_from_pool(my_pool, &threads[i], NULL, thread_func, (void *)1);
    }

    /* Join ULTs */
    for (i = 0; i < num_threads; i++) {
        ret = HTL_thread_join_np(&threads[i]);
    }

    /* Revive ULTs with a different function */
    for (i = 0; i < num_threads; i++) {
        ret = HTL_thread_revive(my_pool, thread_func2, (void *)2, &threads[i]);
    }

    /* Join and free ULTs */
    for (i = 0; i < num_threads; i++) {
        ret = HTL_thread_free(&threads[i]);
    }