[Assorted-commits] SF.net SVN: assorted: [695] sandbox/trunk/src/cc
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-05-02 03:12:44
|
Revision: 695 http://assorted.svn.sourceforge.net/assorted/?rev=695&view=rev Author: yangzhang Date: 2008-05-01 20:12:51 -0700 (Thu, 01 May 2008) Log Message: ----------- added basic st demo Added Paths: ----------- sandbox/trunk/src/cc/st/ sandbox/trunk/src/cc/st/basics.cc Added: sandbox/trunk/src/cc/st/basics.cc =================================================================== --- sandbox/trunk/src/cc/st/basics.cc (rev 0) +++ sandbox/trunk/src/cc/st/basics.cc 2008-05-02 03:12:51 UTC (rev 695) @@ -0,0 +1,42 @@ +#include <cstdio> +#include <iostream> + +#include <commons/check.h> +#include <commons/closing.h> +#include <commons/sockets.h> +#include <commons/st/st.h> + +using namespace std; +using namespace commons; + +void* +f(void *p) +{ + stfd s = tcp_connect("www.google.com", 80); + return NULL; +} + +void* +g(void *p) +{ + st_thread_t t = (st_thread_t) p; + st_sleep(1); + printf("interrupting!\n"); + st_thread_interrupt(t); + printf("interrupted!\n"); + st_sleep(1); + printf("waited\n"); + return NULL; +} + +int +main() +{ + check0(st_init()); + st_thread_t t1 = checkpass(st_thread_create(&f, (void*)"abc", 0, 0)); + checkpass(st_thread_create(&f, (void*)"abc", 0, 0)); + checkpass(st_thread_create(&g, (void*)t1, 0, 0)); + //check0(st_thread_join(t, NULL)); + st_thread_exit(NULL); + return 1; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |