-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmain.cpp
More file actions
41 lines (28 loc) · 805 Bytes
/
main.cpp
File metadata and controls
41 lines (28 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <nodepp/nodepp.h>
#include <nodepp/worker.h>
#include <nodepp/timer.h>
using namespace nodepp;
void onMain(){
ptr_t<int> x = new int(10); mutex_t mut;
worker::add( mutex::add( mut, coroutine::add( COROUTINE(){
coBegin
while( *x > 0 ){
console::log( "wrk2>> Hello World", *x );
*x-=1; coDelay(100); }
coFinish
}) ));
worker::add( mutex::add( mut, coroutine::add( COROUTINE(){
coBegin
while( *x > 0 ){
console::log( "wrk1>> Hello World", *x );
*x-=1; coDelay(100); }
coFinish
}) ));
worker::add( mutex::add( mut, coroutine::add( COROUTINE(){
coBegin
while( *x > 0 ){
console::log( "wrk0>> Hello World", *x );
*x-=1; coDelay(100); }
coFinish
}) ));
}