2022-09-04 22:20:12 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#ifndef FF_INCLUDED_detection_internal
|
|
|
|
|
#define FF_INCLUDED_detection_internal
|
|
|
|
|
|
2022-10-12 14:13:20 +08:00
|
|
|
#include "common/thread.h"
|
2022-09-04 22:20:12 +02:00
|
|
|
|
|
|
|
|
#define FF_DETECTION_INTERNAL_GUARD(ResultType, ...) \
|
2022-10-12 14:13:20 +08:00
|
|
|
static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; \
|
2022-09-04 22:20:12 +02:00
|
|
|
static ResultType result; \
|
|
|
|
|
static bool init = false; \
|
2022-10-12 14:13:20 +08:00
|
|
|
ffThreadMutexLock(&mutex); \
|
2022-09-04 22:20:12 +02:00
|
|
|
if(init) \
|
|
|
|
|
{ \
|
2022-10-12 14:13:20 +08:00
|
|
|
ffThreadMutexUnlock(&mutex); \
|
2022-09-04 22:20:12 +02:00
|
|
|
return &result; \
|
|
|
|
|
} \
|
|
|
|
|
init = true; \
|
|
|
|
|
__VA_ARGS__; \
|
2022-10-12 14:13:20 +08:00
|
|
|
ffThreadMutexUnlock(&mutex); \
|
2022-09-04 22:20:12 +02:00
|
|
|
return &result; \
|
|
|
|
|
|
|
|
|
|
#endif
|