<commit_before>#include <pthread.h>
#include <sys/socket.h>
///thread create function
int dk_thread_func(void (*func)(void)) {
	pthread_t thd;
	pthread_create(&thd,NULL,(void * _Nullable(* _Nonnull)(void * _Nullable))func,NULL);	
	pthread_detach(thd);
	return 1;
}

///master thread
void dk_master_thread(void) {
} 
///worker thread
void dk_worker_thread(void) {
	
}

/// start tcp_server
//  param: work_count  worker thread count
//  	   workers work in a thread pool,
//  	   init work_count size threads
int dk_start(int worker_count = 1) {
	int master_stat = dk_thread_func(dk_master_thread);	
	for(int i = 0; i < worker_count; ++i)
		dk_thread_func(dk_worker_thread);
	return master_stat;
}

<commit_msg>use tool func init master thread<commit_after>#include <pthread.h>
#include <sys/socket.h>
#include "dktool.hpp"
#include <cstdlib>


//// macros 
#define dk_check(val) if(-1 == val) exit(1)
/// constants


/// vars
int dk_listen_port = 0;

///thread create function
int dk_thread_func(void (*func)(void)) {
	pthread_t thd;
	pthread_create(&thd,NULL,(void * _Nullable(* _Nonnull)(void * _Nullable))func,NULL);	
	pthread_detach(thd);
	return 1;
}

///master thread
void dk_master_thread(void) {
	SOCKET sk_fd = dk_socket();
	dk_check(sk_fd);
	sockaddr_in server_addr;
	int stat = dk_bind(sk_fd,dk_listen_port,&server_addr);
	dk_check(stat);
	stat = dk_listen(sk_fd);
	dk_check(stat);
//TODO: multple I/O need support.
	stat = dk_accept(sk_fd,&server_addr);
	dk_check(stat);
} 
///worker thread
void dk_worker_thread(void) {
	
}

/// start tcp_server
//  param: work_count  worker thread count
//  	   workers work in a thread pool,
//  	   init work_count size threads
int dk_start(int worker_count = 1, int listen port) {
	dk_listen_port = listen_port;
	int master_stat = dk_thread_func(dk_master_thread);	
	for(int i = 0; i < worker_count; ++i)
		dk_thread_func(dk_worker_thread);
	return master_stat;
}


{'fraction_non_alphanumeric': 0.13204592901878914, 'fraction_numerical': 0.004697286012526096, 'mean_word_length': 4.556521739130435, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3464976', 'n_tokens_mistral': 751, 'n_tokens_neox': 734, 'n_words': 166}