threadOnce further reduce boilerplate

also latch failure
This commit is contained in:
Michael Davidsaver
2023-09-04 11:26:32 +02:00
parent 59164a63f7
commit d7e49605cc
10 changed files with 76 additions and 59 deletions
+4 -9
View File
@@ -52,10 +52,7 @@ VFunctor0::~VFunctor0() {}
}
static
epicsThreadOnceId evthread_once = EPICS_THREAD_ONCE_INIT;
static
void evthread_init(void* unused)
void evthread_init()
{
#if defined(EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED)
evthread_use_windows_threads();
@@ -147,7 +144,7 @@ struct evbase::Pvt final : public epicsThreadRunable
epicsThreadGetStackSize(epicsThreadStackBig),
prio)
{
threadOnce(&evthread_once, &evthread_init, nullptr);
threadOnce<&evthread_init>();
worker.start();
start_sync.wait();
@@ -699,19 +696,17 @@ bool evsocket::init_canIPv6() noexcept
# define getMonotonic getCurrent
#endif
static epicsThreadOnceId mapOnce = EPICS_THREAD_ONCE_INIT;
static IfaceMap* theinstance;
static
void mapInit(void*)
void mapInit()
{
theinstance = new IfaceMap();
}
IfaceMap& IfaceMap::instance()
{
threadOnce(&mapOnce, &mapInit);
threadOnce<&mapInit>();
assert(theinstance);
return *theinstance;
}