<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <numa.h>
#include <pthread.h>

#include "thread.h"
#include "common.h"

void *thread_run(void *arg)
{
	thread *t = (thread *) arg;
	pthread_setspecific(thread::thread_key, t);

	int node_id = t->get_node_id();
	if (node_id >= 0)
		bind2node_id(node_id);
	t->init();
	while (t->is_running()) {
		t->run();
		if (t->is_blocking())
			t->wait();
	}
	t->cleanup();
	t->exit();
	return NULL;
}

void thread::start()
{
	assert(id == 0);
	int ret = pthread_create(&id, NULL, thread_run, (void *) this);
	if (ret) {
		perror("pthread_create");
		::exit(1);
	}
}

static pthread_once_t once_control = PTHREAD_ONCE_INIT;

void init_thread_class()
{
	printf("init thread key\n");
	pthread_key_create(&thread::thread_key, NULL);
}

void thread::thread_class_init()
{
	pthread_once(&once_control, init_thread_class);
}

thread *thread::get_curr_thread()
{
	thread *curr = (thread *) pthread_getspecific(thread_key);
	return curr;
}

pthread_key_t thread::thread_key;

class thread_representer: public thread
{
	void run() {
	}
public:
	thread_representer(int node_id): thread(std::string(
				"representer-thread-node") + itoa(node_id), node_id) {
	}
};

thread *thread::represent_thread(int node_id)
{
	thread *curr = thread::get_curr_thread();
	assert(curr == NULL);
	curr = new thread_representer(node_id);
	pthread_setspecific(thread::thread_key, curr);<commit_msg>Bind the thread to a specified node.<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <numa.h>
#include <pthread.h>

#include "thread.h"
#include "common.h"

void *thread_run(void *arg)
{
	thread *t = (thread *) arg;
	pthread_setspecific(thread::thread_key, t);

	int node_id = t->get_node_id();
	if (node_id >= 0)
		bind2node_id(node_id);
	t->init();
	while (t->is_running()) {
		t->run();
		if (t->is_blocking())
			t->wait();
	}
	t->cleanup();
	t->exit();
	return NULL;
}

void thread::start()
{
	assert(id == 0);
	int ret = pthread_create(&id, NULL, thread_run, (void *) this);
	if (ret) {
		perror("pthread_create");
		::exit(1);
	}
}

static pthread_once_t once_control = PTHREAD_ONCE_INIT;

void init_thread_class()
{
	printf("init thread key\n");
	pthread_key_create(&thread::thread_key, NULL);
}

void thread::thread_class_init()
{
	pthread_once(&once_control, init_thread_class);
}

thread *thread::get_curr_thread()
{
	thread *curr = (thread *) pthread_getspecific(thread_key);
	return curr;
}

pthread_key_t thread::thread_key;

class thread_representer: public thread
{
	void run() {
	}
public:
	thread_representer(int node_id): thread(std::string(
				"representer-thread-node") + itoa(node_id), node_id) {
	}
};

thread *thread::represent_thread(int node_id)
{
	if (node_id >= 0)
		bind2node_id(node_id);

	thread *curr = thread::get_curr_thread();
	assert(curr == NULL);
	curr = new thread_representer(node_id);
	pthread_setspecific(thread::thread_key, curr);
{'fraction_non_alphanumeric': 0.1672401927047488, 'fraction_numerical': 0.0034411562284927736, 'mean_word_length': 5.621867881548975, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 30, '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': '1734390', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1136, 'n_words': 219}