Skip to content

Commit 6423fab

Browse files
author
zhengshuxin
committed
Test fiber demo.
1 parent d7cb15a commit 6423fab

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

lib_fiber/c/src/fiber.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ static void thread_init(void)
183183
ring_init(&local->dead);
184184

185185
#ifdef THREAD_LOCAL_DYNAMIC
186+
# if defined(_WIN32) || defined(_WIN64)
186187
pthread_fkey_create();
188+
# endif
187189

188190
if (pthread_setspecific(__fiber_key, local) != 0) {
189191
printf("pthread_setspecific error!\r\n");

lib_fiber/samples-c++1x/httpc/httpc.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static void usage(const char* procname) {
4949
, procname);
5050
}
5151

52+
#ifdef _TEST
5253
static void fiber_main(ACL_FIBER *, void*) {
5354
printf("hello world!\r\n");
5455
acl::fiber::delay(100);
@@ -61,6 +62,7 @@ static void test() {
6162
printf("Bye!\r\n");
6263
}
6364
}
65+
#endif
6466

6567
int main(int argc, char *argv[]) {
6668
int ch, nfiber = 1, count = 100;
@@ -69,7 +71,18 @@ int main(int argc, char *argv[]) {
6971
acl::acl_cpp_init();
7072
acl::log::stdout_open(true);
7173

74+
#ifdef _TEST
75+
# if defined(_WIN32) || defined(_WIN64)
7276
test();
77+
return 0;
78+
# else
79+
std::thread thr([] {
80+
test();
81+
});
82+
thr.join();
83+
return 0;
84+
# endif
85+
#endif
7386

7487
while ((ch = getopt(argc, argv, "he:s:c:n:")) > 0) {
7588
switch (ch) {

0 commit comments

Comments
 (0)