ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
thread.c
Go to the documentation of this file.
1
10#include "thread.h"
11#include "common.h"
12#include "log/logging.h"
13
14asciichat_error_t thread_create_or_fail(asciichat_thread_t *thread, void *(*func)(void *), void *arg,
15 const char *thread_name, uint32_t client_id) {
16 if (!thread || !func || !thread_name) {
17 return SET_ERRNO(ERROR_INVALID_PARAM, "Invalid parameters for thread creation");
18 }
19
20 int result = asciichat_thread_create(thread, func, arg);
21 if (result != 0) {
22 return SET_ERRNO(ERROR_PLATFORM_INIT, "Failed to create %s thread for client %u (result=%d)", thread_name,
23 client_id, result);
24 }
25
26 log_debug("Created %s thread for client %u successfully", thread_name, client_id);
27 return ASCIICHAT_OK;
28}
unsigned int uint32_t
Definition common.h:58
#define SET_ERRNO(code, context_msg,...)
Set error code with custom context message and log it.
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:46
@ ERROR_PLATFORM_INIT
Definition error_codes.h:57
@ ASCIICHAT_OK
Definition error_codes.h:48
@ ERROR_INVALID_PARAM
#define log_debug(...)
Log a DEBUG message.
asciichat_error_t thread_create_or_fail(asciichat_thread_t *thread, void *(*func)(void *), void *arg, const char *thread_name, uint32_t client_id)
Create a thread with standardized error handling and logging.
Definition thread.c:14
pthread_t asciichat_thread_t
Thread handle type (POSIX: pthread_t)
int asciichat_thread_create(asciichat_thread_t *thread, void *(*func)(void *), void *arg)
Create a new thread.
๐Ÿ“ Logging API with multiple log levels and terminal output control
๐Ÿงต Thread lifecycle management helpers