Skip to content

Commit 4a59884

Browse files
author
zhengshuxin
committed
Test epoll oneshot mode.
1 parent 937e324 commit 4a59884

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

lib_fiber/samples-c++/fiber_tbox/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ static int __total_count = 2;
77
static int __diff_delay = 10000;
88
static int __delay = 10;
99
static acl::fiber_event_t __event_type = acl::FIBER_EVENT_T_KERNEL;
10-
static acl::atomic_long __producing = 0;
11-
static acl::atomic_long __consuming = 0;
12-
static acl::atomic_long __timedout = 0;
10+
static acl::atomic_long __producing;
11+
static acl::atomic_long __consuming;
12+
static acl::atomic_long __timedout;
1313

1414
class myobj
1515
{

lib_fiber/samples-c++1x/fiber_tbox3/main.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
#include "stdafx.h"
2+
#include <thread>
23
#include <stdio.h>
34
#include <stdlib.h>
45

56
int main()
67
{
78
acl::fiber_tbox<int> box;
89

9-
go[&box] {
10+
#define THREAD_PRODUCER
11+
#ifdef THREAD_PRODUCER
12+
std::thread thr([&box] {
13+
#else
14+
go([&box] {
15+
#endif
1016
for (int i = 0; i < 10000; i++) {
1117
int *n = new int(i);
1218
printf("fiber-%d: Push %d\r\n", acl::fiber::self(), *n);
1319
box.push(n);
1420
acl::fiber::delay(1000);
1521
}
16-
};
22+
});
23+
1724

25+
acl::fiber::set_event_keepio(true);
26+
acl::fiber::set_event_oneshot(true);
1827

1928
go[&box] {
2029
while (true) {

0 commit comments

Comments
 (0)