File: thread.cpp

package info (click to toggle)
tippecanoe 2.53.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 148,236 kB
  • sloc: cpp: 44,069; ansic: 2,057; makefile: 454; perl: 129; python: 62; sh: 4
file content (22 lines) | stat: -rw-r--r-- 796 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdlib.h>
#include "thread.hpp"

// It is harder to profile tippecanoe because of its normal use of multiple threads.
// If you set TIPPECANOE_NO_THREADS in the environment, it will run everything in
// the main thread instead for more straightforward profiling. (The threads will
// then still be created so they will be reaped, but they will immediately return.)

static const char *no_threads = getenv("TIPPECANOE_NO_THREADS");

static void *do_nothing(void *arg) {
	return arg;
}

int thread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) {
	if (no_threads != NULL) {
		void *ret = start_routine(arg);
		return pthread_create(thread, attr, do_nothing, ret);
	} else {
		return pthread_create(thread, attr, start_routine, arg);
	}
}