MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / start

Method start

source/core/StarThread_unix.cpp:61–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 : function(std::move(function)), name(std::move(name)), stopped(true), joined(true) {}
60
61 bool start() {
62 MutexLocker mutexLocker(mutex);
63 if (!joined)
64 return false;
65
66 stopped = false;
67 joined = false;
68 int ret = pthread_create(&pthread, NULL, &runThread, (void*)this);
69 if (ret != 0) {
70 stopped = true;
71 joined = true;
72 throw StarException(strf("Failed to create thread, error {}", ret));
73 }
74
75 // ensure the name is under the max allowed
76 char tname[MAX_THREAD_NAMELEN];
77 snprintf(tname, sizeof(tname), "%s", name.utf8Ptr());
78
79#ifdef STAR_SYSTEM_FREEBSD
80 pthread_set_name_np(pthread, tname);
81#elif defined(STAR_SYSTEM_NETBSD)
82 pthread_setname_np(pthread, "%s", tname);
83#elif not defined STAR_SYSTEM_MACOS
84 pthread_setname_np(pthread, tname);
85#endif
86 return true;
87 }
88
89 bool join() {
90 MutexLocker mutexLocker(mutex);

Callers

nothing calls this directly

Calls 4

pthread_createFunction · 0.85
StarExceptionClass · 0.85
strfFunction · 0.85
utf8PtrMethod · 0.45

Tested by

no test coverage detected