ZaStoGram_desktop/Telegram/SourceFiles/_other/widget_helper_thread_mac.cpp
John Preston 15c2c8bab5 Run widget validators and renderers in the macOS helper
Task: 2026/11/14/run-widget-validators-and-renderers-in-the-macos-helper
2026-11-19 23:17:09 +04:00

37 lines
972 B
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "_other/widget_helper_thread_mac.h"
#include <gsl/gsl>
#include <pthread.h>
namespace WidgetHelper {
int StartDetachedThread(void *(*entry)(void*), void *argument) {
auto attributes = pthread_attr_t();
if (const auto error = pthread_attr_init(&attributes)) {
return error;
}
const auto destroy = gsl::finally([&] {
pthread_attr_destroy(&attributes);
});
if (const auto error = pthread_attr_setstacksize(
&attributes,
kThreadStackBytes)) {
return error;
} else if (const auto error = pthread_attr_setdetachstate(
&attributes,
PTHREAD_CREATE_DETACHED)) {
return error;
}
auto thread = pthread_t();
return pthread_create(&thread, &attributes, entry, argument);
}
} // namespace WidgetHelper