Skip to content

Commit 136ed8d

Browse files
committed
📌 Nodepp | Stable Version | V1.5.0 📌
1 parent e9b1866 commit 136ed8d

140 files changed

Lines changed: 6063 additions & 3079 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
image.jpg
21
main.exe
32
build
43
main

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.6)
22
project(nodepp VERSION 1.3.0)
33

44
set(CMAKE_CXX_STANDARD 11)

benchmark/server_benchmark/nodepp_benchmark.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#define NODEPP_ALLOW_THREADS 0
2-
31
#include <nodepp/nodepp.h>
42
#include <nodepp/http.h>
53

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <nodepp/nodepp.h>
2+
#include <nodepp/worker.h>
3+
#include <nodepp/http.h>
4+
#include <nodepp/os.h>
5+
6+
using namespace nodepp;
7+
8+
void onParallel(){
9+
10+
auto server = http::server([=]( http_t cli ){
11+
12+
// console::log( cli.path, cli.get_fd() );
13+
14+
cli.write_header( 200, header_t({
15+
{ "content-type", "text/html" }
16+
}));
17+
18+
cli.write( "<h1>Hello, World!</h1>" );
19+
20+
});
21+
22+
server.listen( "localhost", 8000, [=]( socket_t server ){
23+
console::log("server started at http://localhost:8000");
24+
});
25+
26+
}
27+
28+
void onMain(){
29+
worker::parallel( &onParallel, os::cpus() ); }
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#define MAX_BATCH 10
2+
13
#include <nodepp/nodepp.h>
24
#include <nodepp/worker.h>
35
#include <nodepp/http.h>
@@ -121,4 +123,5 @@ void onMain(){
121123

122124
}
123125

124-
/*────────────────────────────────────────────────────────────────────────────*/
126+
/*────────────────────────────────────────────────────────────────────────────*/
127+
// BUGFIXED
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#define MAX_BATCH 10
2+
3+
/*────────────────────────────────────────────────────────────────────────────*/
4+
15
#include <nodepp/nodepp.h>
26
#include <nodepp/worker.h>
37
#include <nodepp/timer.h>
@@ -6,8 +10,12 @@
610
#include <nodepp/ws.h>
711
#include <nodepp/fs.h>
812

13+
/*────────────────────────────────────────────────────────────────────────────*/
14+
915
using namespace nodepp;
1016

17+
/*────────────────────────────────────────────────────────────────────────────*/
18+
1119
void server(){
1220

1321
auto server = http::server([=]( http_t cli ){
@@ -48,6 +56,8 @@ void server(){
4856

4957
}
5058

59+
/*────────────────────────────────────────────────────────────────────────────*/
60+
5161
void client() {
5262

5363
auto client = ws::client( "ws://localhost:8000/" );
@@ -65,6 +75,8 @@ void client() {
6575

6676
}
6777

78+
/*────────────────────────────────────────────────────────────────────────────*/
79+
6880
void onMain() {
6981

7082
worker::add( coroutine::add( COROUTINE(){
@@ -75,14 +87,17 @@ void onMain() {
7587
coBegin
7688

7789
while( true ){
90+
while( process::size() > MAX_BATCH ){ coDelay(1000); }
7891

79-
worker::add( coroutine::add( COROUTINE(){
80-
coBegin /*--*/ ; client();
81-
process::wait(); coFinish }));
92+
worker::add([=](){ client();
93+
process::wait(); return -1; });
8294

83-
coDelay( 10 ); }
95+
coNext; }
8496

8597
coFinish
8698
}));
8799

88-
}
100+
}
101+
102+
/*────────────────────────────────────────────────────────────────────────────*/
103+
// BUGFIXED

benchmark/stress-test/3-worker.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#define MAX_BATCH 10
2+
3+
/*────────────────────────────────────────────────────────────────────────────*/
4+
5+
#include <nodepp/nodepp.h>
6+
#include <nodepp/worker.h>
7+
#include <nodepp/timer.h>
8+
#include <nodepp/atomic.h>
9+
10+
/*────────────────────────────────────────────────────────────────────────────*/
11+
12+
using namespace nodepp;
13+
14+
/*────────────────────────────────────────────────────────────────────────────*/
15+
16+
void onWorker(){
17+
18+
process::add( coroutine::add( COROUTINE(){
19+
coBegin
20+
21+
while( true ){
22+
console::log( "hello world", (void*) worker::pid() );
23+
coDelay( rand() % 1000 ); process::clear(); }
24+
25+
coFinish
26+
}));
27+
28+
}
29+
30+
/*────────────────────────────────────────────────────────────────────────────*/
31+
32+
void onMain(){
33+
34+
process::add( coroutine::add( COROUTINE(){
35+
coBegin
36+
37+
while( true ){
38+
while( process::size() > MAX_BATCH ){ coDelay(100); }
39+
40+
worker::add([=](){
41+
console::log( "--->", process::size() );
42+
onWorker ();
43+
process::wait(); return -1; });
44+
45+
coNext; }
46+
47+
coFinish
48+
}));
49+
50+
}
51+
52+
/*────────────────────────────────────────────────────────────────────────────*/
53+
// BUGFIXED
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
#define MAX_BATCH 10
2+
3+
/*────────────────────────────────────────────────────────────────────────────*/
4+
15
#include <nodepp/nodepp.h>
26
#include <nodepp/event.h>
37

48
using namespace nodepp;
59

10+
/*────────────────────────────────────────────────────────────────────────────*/
11+
612
void onMain(){
713

814
event_t<> ev;
@@ -42,4 +48,7 @@ void onMain(){
4248

4349
console::log( "EEE" );
4450

45-
}
51+
}
52+
53+
/*────────────────────────────────────────────────────────────────────────────*/
54+
// BUGFIXED
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
#include <nodepp/nodepp.h>
1+
#define MAX_BATCH 10
2+
3+
/*────────────────────────────────────────────────────────────────────────────*/
24

5+
#include <nodepp/nodepp.h>
36
using namespace nodepp;
47

8+
/*────────────────────────────────────────────────────────────────────────────*/
9+
510
void onMain() {
611

712
process::add([=](){
@@ -31,4 +36,7 @@ void onMain() {
3136

3237
process::add([=](){ console::log( "---" ); return 1; });
3338

34-
}
39+
}
40+
41+
/*────────────────────────────────────────────────────────────────────────────*/
42+
// BUGFIXED
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#define MAX_BATCH 10
2+
3+
/*────────────────────────────────────────────────────────────────────────────*/
4+
5+
#include <nodepp/nodepp.h>
6+
#include <nodepp/promise.h>
7+
8+
/*────────────────────────────────────────────────────────────────────────────*/
9+
10+
using namespace nodepp;
11+
12+
/*────────────────────────────────────────────────────────────────────────────*/
13+
14+
void resolve(){
15+
16+
promise_t<null_t,except_t> ([=](
17+
res_t<null_t> res, rej_t<except_t> rej
18+
){
19+
20+
process::add( coroutine::add( COROUTINE(){
21+
coBegin
22+
23+
coDelay( 10 ); res( nullptr );
24+
resolve(); // <- this must create a memory leak | bug fixed :)
25+
26+
coFinish
27+
}));
28+
29+
})
30+
31+
.then([=]( null_t ){
32+
console::log( "done" );
33+
})
34+
35+
.fail([=]( except_t ){
36+
console::log( "error" );
37+
});
38+
39+
}
40+
41+
/*────────────────────────────────────────────────────────────────────────────*/
42+
43+
void onMain(){ resolve(); }
44+
45+
/*────────────────────────────────────────────────────────────────────────────*/
46+
// BUGFIXED

0 commit comments

Comments
 (0)