| 45 | } |
| 46 | } |
| 47 | int main( int argc,char *argv[] ) |
| 48 | { |
| 49 | vector< stCoClosure_t* > v; |
| 50 | |
| 51 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; |
| 52 | |
| 53 | int total = 100; |
| 54 | vector<int> v2; |
| 55 | co_ref( ref,total,v2,m); |
| 56 | for(int i=0;i<10;i++) |
| 57 | { |
| 58 | co_func( f,ref,i ) |
| 59 | { |
| 60 | printf("ref.total %d i %d\n",ref.total,i ); |
| 61 | //lock |
| 62 | pthread_mutex_lock(&ref.m); |
| 63 | ref.v2.push_back( i ); |
| 64 | pthread_mutex_unlock(&ref.m); |
| 65 | //unlock |
| 66 | } |
| 67 | co_func_end; |
| 68 | v.push_back( new f( ref,i ) ); |
| 69 | } |
| 70 | for(int i=0;i<2;i++) |
| 71 | { |
| 72 | co_func( f2,i ) |
| 73 | { |
| 74 | printf("i: %d\n",i); |
| 75 | for(int j=0;j<2;j++) |
| 76 | { |
| 77 | usleep( 1000 ); |
| 78 | printf("i %d j %d\n",i,j); |
| 79 | } |
| 80 | } |
| 81 | co_func_end; |
| 82 | v.push_back( new f2( i ) ); |
| 83 | } |
| 84 | |
| 85 | batch_exec( v ); |
| 86 | printf("done\n"); |
| 87 | |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 |
nothing calls this directly
no test coverage detected