-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
204583b
commit fdc42a1
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <stdlib.h> | ||
|
||
#include "platform.h" | ||
|
||
static int g_once_count = 0; | ||
|
||
static void init() | ||
{ | ||
g_once_count++; | ||
} | ||
|
||
int test_call_once() | ||
{ | ||
static ncnn::OnceFlag flag = OnceFlagInit; | ||
ncnn::CallOnce(flag, &init); | ||
ncnn::CallOnce(flag, &init); | ||
ncnn::CallOnce(flag, &init); | ||
|
||
if (g_once_count != 1) | ||
return EXIT_FAILURE; | ||
return EXIT_SUCCESS; | ||
} | ||
|
||
int main() | ||
{ | ||
int ret; | ||
|
||
ret = test_call_once(); | ||
if (ret) | ||
return ret; | ||
|
||
return 0; | ||
} |