@@ -44,13 +44,14 @@ target_link_libraries( #[...]
4444
4545- 📌: Include a ** build-in JSON** parser / stringify system.
4646- 📌: Include a ** build-in RegExp** engine for processing text strings.
47- - 📌: Include Support for ** UTF** manipulation | ** UTF8 - UTF16 - UTF32**
47+ - 📌: Include support for ** UTF** manipulation | ** UTF8 - UTF16 - UTF32**
4848- 📌: Include a ** build-in System** that make every object ** Async Task** safety.
4949- 📌: Include a ** Smart Pointer** base ** Garbage Collector** to avoid ** Memory Leaks** .
5050- 📌: Include support for ** Reactive Programming** based on ** Events** and ** Observers** .
5151- 📌: Include an ** Event Loop** that can handle multiple events and tasks on a single thread.
5252- 📌: Include support for ** TCP | TLS | UDP | HTTP | WS** making it easy to create networked applications.
53- - 📌: Include Support for ** Poll | Epoll | Kqueue | WSAPoll** making it easy to handle multiple file descriptors.
53+ - 📌: Include support for ** Poll | Epoll | Kqueue | WSAPoll** making it easy to handle multiple file descriptors.
54+ - 📌: Include support for ** Worker isolated event-loop** making it easy to create distributed self-contained event-loops.
5455
5556## Build & Run
5657``` bash
@@ -160,6 +161,47 @@ void onMain(){
160161}
161162```
162163
164+ ### Worker Isolated Event-Loop
165+ ``` cpp
166+ #include < nodepp/nodepp.h>
167+ #include < nodepp/worker.h>
168+ #include < nodepp/os.h>
169+
170+ using namespace nodepp ;
171+
172+ atomic_t <int > shared_variable = 100 ;
173+
174+ void local_main ( int cpu_id ){
175+
176+ // this event-loop runs in it's own isolated worker-thread
177+
178+ process::add( coroutine::add( COROUTINE(){
179+ thread_local static int variable; // aka thread_safe variable;
180+ // this will create a static variable per thread
181+ static atomic_t<int> shared_variable;
182+ // this will create a shared global variable
183+ int local_variable;
184+ // this is a normal variable only exists in here
185+ coBegin
186+
187+ while( shared_variable-->0 ){
188+ console::log( cpu_id, "->", shared_variable.get() );
189+ coDelay(1000); }
190+
191+ coFinish
192+ }));
193+
194+ }
195+
196+ void onMain(){
197+
198+ for( auto x=os::cpus(); x-->0; ){ worker::add([=](){
199+ local_main( x ); process::wait();
200+ return -1; }); }
201+
202+ }
203+ ```
204+
163205### More Examples [here](https://nodeppofficial.github.io/nodepp-doc/guide.html)
164206
165207## Installing Nodepp
0 commit comments