<commit_before>#include <libblossom/blossom.h>

int blossom_pthreads(blossom_state *ctx,const pthread_attr_t *attr,
			void *(*fxn)(void *),void *arg){
	unsigned z;

	for(z = 0 ; z < ctx->tidcount ; ++z){
		int ret;

		if( (ret = pthread_create(&ctx->tids[z],attr,fxn,arg)) ){
			// FIXME cleanup spawned threads...how?
			return ret;
		}
	}
	return 0;
}<commit_msg>move past naive spawn to actual blossom skeleton<commit_after>#include <errno.h>
#include <stdlib.h>
#include <libblossom/blossom.h>

// This is the simple, O(N) latency pthread creation
/* int blossom_pthreads(blossom_state *ctx,const pthread_attr_t *attr,
			void *(*fxn)(void *),void *arg){
	unsigned z;

	for(z = 0 ; z < ctx->tidcount ; ++z){
		int ret;

		if( (ret = pthread_create(&ctx->tids[z],attr,fxn,arg)) ){
			// FIXME cleanup spawned threads...how?
			return ret;
		}
	}
	return 0;
} */

typedef struct blossom {
	unsigned idx;
	blossom_state *ctx;
	const pthread_attr_t *attr;
	void *arg;
} blossom;

static void *
blossom_thread(void *unsafeb){
	blossom *b = unsafeb;

	if(b->idx != b->ctx->tidcount){
		// spawn new one FIXME
	}
	pthread_exit(NULL);
}

// pthreads return semantics (positive error code in result, errno ignored)
int blossom_pthreads(blossom_state *ctx,const pthread_attr_t *attr,
			void *(*fxn)(void *),void *arg){
	unsigned z;
	blossom *b;
	int ret;

	if(ctx->tidcount <= 0){
		return EINVAL;
	}
	if((b = malloc(sizeof(*b))) == NULL){
		return errno;
	}
	b->idx = 0;
	b->ctx = ctx;
	b->attr = attr;
	b->arg = arg;
	if( (ret = pthread_create(&ctx->tids[0],attr,fxn,b)) ){
		free(b);
		return ret;
	}
	// FIXME verify all were spawned
	return 0;
}
{'fraction_non_alphanumeric': 0.1646415552855407, 'fraction_numerical': 0.004860267314702308, 'mean_word_length': 3.960843373493976, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 20, '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': '482563', 'n_tokens_mistral': 713, 'n_tokens_neox': 657, 'n_words': 163}