BitLab 0.1.0
BitLab: A Browser for the Bitcoin P2P Network and Blockchain
Loading...
Searching...
No Matches
thread.h File Reference
#include <stdio.h>
#include <pthread.h>

Go to the source code of this file.

Functions

pthread_t thread_runner (void *(*start_routine)(void *), const char *name, void *arg)
 Thread runner function.
 

Function Documentation

◆ thread_runner()

pthread_t thread_runner ( void *(*)(void *)  start_routine,
const char *  name,
void *  arg 
)

Thread runner function.

This function is used to create a new thread.

Parameters
start_routineThe function pointer to the start routine.
nameThe name of the thread.
argThe argument to pass to the start routine.

Definition at line 9 of file thread.c.

10{
11 pthread_t thread;
12 if (pthread_create(&thread, NULL, start_routine, arg) != 0)
13 log_message(LOG_WARN, BITLAB_LOG, __FILE__, "%s thread creation failed: %s", name, strerror(errno));
14 log_message(LOG_INFO, BITLAB_LOG, __FILE__, "%s thread started", name);
15 return thread;
16}
void log_message(log_level level, const char *filename, const char *source_file, const char *format,...)
Log a message used to log a message to the console or a file.
Definition log.c:89
#define BITLAB_LOG
Definition log.h:11
@ LOG_INFO
Definition log.h:30
@ LOG_WARN
Definition log.h:31

References BITLAB_LOG, LOG_INFO, log_message(), and LOG_WARN.

Referenced by run_bitlab().