diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/httpget.c | 9 | ||||
| -rw-r--r-- | test/read.c | 8 | ||||
| -rw-r--r-- | test/simple1.c | 8 | ||||
| -rw-r--r-- | test/sleep.c | 6 | 
4 files changed, 16 insertions, 15 deletions
diff --git a/test/httpget.c b/test/httpget.c index 29f7f14..876b63c 100644 --- a/test/httpget.c +++ b/test/httpget.c @@ -14,6 +14,7 @@ static void ping_fiber(void *ptr)  	struct ctx *ctx = (struct ctx*) ptr;  	struct tf_sockaddr host;  	struct tf_fd fd; +	struct tf_timeout to;  	char buf[128];  	int bytes = 0, r;  	const char *req = "GET / HTTP/1.0\r\n\r\n"; @@ -27,7 +28,7 @@ static void ping_fiber(void *ptr)  	if (r < 0)  		goto err; -	r = tf_timed(tf_connect(&fd, &host), 10000); +	r = tf_timed(&to, tf_connect(&fd, &host), 10000);  	if (r < 0)  		goto err_close; @@ -49,11 +50,11 @@ int main(int argc, char **argv)  	struct ctx *c;  	int i; -	tf_scheduler_enable(NULL); +	tf_vmach_start();  	for (i = 1; i < argc; i++) {  		c = tf_fiber_create(ping_fiber, sizeof(struct ctx));  		c->hostname = argv[i]; -		tf_fiber_put(c); +		tf_fiber_run(c);  	} -	tf_scheduler_disable(); +	tf_vmach_stop();  } diff --git a/test/read.c b/test/read.c index 0dc72cc..9963a62 100644 --- a/test/read.c +++ b/test/read.c @@ -34,8 +34,8 @@ static void io_fiber(void *ptr)  int main(int argc, char **argv)  { -	tf_scheduler_enable(NULL); -	tf_fiber_put(tf_fiber_create(time_fiber, 0)); -	tf_fiber_put(tf_fiber_create(io_fiber, 0)); -	tf_scheduler_disable(); +	tf_vmach_start(); +	tf_fiber_run(tf_fiber_create(time_fiber, 0)); +	tf_fiber_run(tf_fiber_create(io_fiber, 0)); +	tf_vmach_stop();  } diff --git a/test/simple1.c b/test/simple1.c index 6f40f8d..b6de289 100644 --- a/test/simple1.c +++ b/test/simple1.c @@ -10,7 +10,7 @@ static void work_fiber(void *ptr)  	struct ctx *c = (struct ctx*) ptr;  	printf("Hello%d.1\n", c->id); -	tf_fiber_yield(); +	tf_msleep(1);  	printf("Hello%d.2\n", c->id);  } @@ -19,11 +19,11 @@ int main(int argc, char **argv)  	struct ctx *c;  	int i; -	tf_scheduler_enable(NULL); +	tf_vmach_start();  	for (i = 0; i < 6; i++) {  		c = tf_fiber_create(work_fiber, sizeof(struct ctx));  		c->id = i; -		tf_fiber_put(c); +		tf_fiber_run(c);  	} -	tf_scheduler_disable(); +	tf_vmach_stop();  } diff --git a/test/sleep.c b/test/sleep.c index 8e225a7..dd71d91 100644 --- a/test/sleep.c +++ b/test/sleep.c @@ -21,10 +21,10 @@ int main(int argc, char **argv)  	struct ctx *c;  	int i; -	tf_scheduler_enable(NULL); +	tf_vmach_start();  	for (i = 0; i < 1000; i++) {  		c = tf_fiber_create(work_fiber, sizeof(struct ctx)); -		tf_fiber_put(c); +		tf_fiber_run(c);  	} -	tf_scheduler_disable(); +	tf_vmach_stop();  }  | 
