2.5.2 Thread — Zix 0.8.2 documentation

# 2.5.2 Thread

ZIX_THREAD_FUNC

  Thread function attribute.

ZIX_THREAD_RESULT

  NULL

  Result returned from a thread function.

typedef pthread_t ZixThread

  A thread.

typedef ZixThreadResult (*ZixThreadFunc)(void*)

  A thread function.

  For portability reasons, the return type varies between platforms, and the return value is ignored. Thread functions should always return `ZIX_THREAD_RESULT`. This allows thread functions to be used directly by the system without any wrapper overhead.

  “Returning” a result, and communicating with the parent thread in general, can be done through the pointer argument.

typedef void *ZixThreadResult

  Thread function return type.

ZixStatus zix_thread_create(ZixThread *thread, size_t stack_size, ZixThreadFunc function, void *arg)

  Initialize `thread` to a new thread.

  The thread will immediately be launched, calling `function` with `arg` as the only parameter.

  Returns:

    `ZixStatus.ZIX_STATUS_SUCCESS` on success, or `ZixStatus.ZIX_STATUS_ERROR`.

ZixStatus zix_thread_join(ZixThread thread)

  Join `thread` (block until `thread` exits).

  Returns:

    `ZixStatus.ZIX_STATUS_SUCCESS` on success, or `ZixStatus.ZIX_STATUS_ERROR`.