Skip to content

Commit 8f8800e

Browse files
committed
📌 Nodepp | Stable Release | V1.4.6 📌
1 parent 6bba1c2 commit 8f8800e

4 files changed

Lines changed: 66 additions & 12 deletions

File tree

compile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#echo "[windows]"; time x86_64-w64-mingw32-g++ main.cpp -D_WIN32_WINNT=0x0601 -o main.exe -I./include -lkernel32 -static-libgcc -static-libstdc++ -static -lws2_32 -g ; wine main.exe
2-
echo "[linux]" ; time g++ -o main main.cpp -I./include -lssl -lcrypto -lz -std=c++20 ; ./main
2+
echo "[linux]" ; time g++ -o main main.cpp -I./include -lssl -lcrypto -lz -std=c++20 -O3 ; ./main
33

44
#wine debuggin mode
55
#server: winedbg --gdb --port 12345 --no-start ./main.exe

include/nodepp/array.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,20 @@ namespace nodepp { template< class T > class array_t {
455455

456456
/*────────────────────────────────────────────────────────────────────────────*/
457457

458+
namespace nodepp {
459+
460+
template< class T >
461+
array_t<T> operator+( const array_t<T>& A, const array_t<T>& B ){
462+
if( A.empty() ){ return B; } if( B.empty() ){ return A; }
463+
ptr_t<T> C( A.size() + B.size() ); /*--------------*/
464+
type::copy( B.begin(), B.end(), C.begin()+A.size() );
465+
type::copy( A.begin(), A.end(), C.begin() ); return C;
466+
}
467+
468+
}
469+
470+
/*────────────────────────────────────────────────────────────────────────────*/
471+
458472
#endif
459473

460474
/*────────────────────────────────────────────────────────────────────────────*/

include/nodepp/iterator.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,6 @@ namespace nodepp { namespace string {
184184
/*────────────────────────────────────────────────────────────────────────────*/
185185

186186
namespace nodepp { namespace string {
187-
188-
template< class T >
189-
array_t<T> operator+( const array_t<T>& A, const array_t<T>& B ){
190-
if( A.empty() ){ return B; } if( B.empty() ){ return A; }
191-
ptr_t<T> C( A.size() + B.size() ); /*--------------*/
192-
type::copy( B.begin(), B.end(), C.begin()+A.size() );
193-
type::copy( A.begin(), A.end(), C.begin() ); return C;
194-
}
195-
196-
/*─······································································─*/
197187

198188
template< class T >
199189
string_t join( const initializer_t<T>& raw, string_t c=", " ){

main.cpp

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,62 @@
11
#include <nodepp/nodepp.h>
2+
#include <nodepp/worker.h>
3+
#include <nodepp/date.h>
4+
#include <nodepp/http.h>
5+
#include <nodepp/cluster.h>
26

37
using namespace nodepp;
48

59
/*────────────────────────────────────────────────────────────────────────────*/
610

11+
void server( int x ){
12+
13+
auto server = http::server([=]( http_t cli ){
14+
15+
cli.write_header( 200, header_t({
16+
{ "content-type", "text/html" }
17+
}));
18+
19+
cli.write( date::fulltime() );
20+
cli.close();
21+
22+
});
23+
24+
server.listen( "localhost", 8000, [=]( socket_t server ){
25+
console::log("server started at http://localhost:8000");
26+
});
27+
28+
}
29+
30+
/*────────────────────────────────────────────────────────────────────────────*/
31+
32+
void spawn( int x ) {
33+
34+
auto cid = regex::format( "?CPU=${0}", x );
35+
auto pid = cluster::add( ptr_t<string_t>({ cid }) );
36+
37+
if( pid.has_value() ){
38+
pid.value().onClose.once([=](){ spawn(x); });
39+
pid.value().onData([=]( string_t msg ){
40+
conio::log( msg );
41+
});
42+
}
43+
44+
}
45+
46+
/*────────────────────────────────────────────────────────────────────────────*/
47+
748
void onMain(){
849

9-
console::log( string::join( ptr_t<int>({ 10, 20, 30 }) ) );
50+
os::set_process_priority( os::PRIORITY::HIGH_PRIORITY );
51+
os::set_hard_fileno/*-*/( (uint)-1 );
52+
os::set_soft_fileno/*-*/( (uint)-1 );
53+
54+
int y = string::to_uint( process::env::get( "CPU" ) );
55+
56+
for ( auto x=os::cpus(); x-->0; ){
57+
if ( cluster::is_child() )
58+
{ server(y); break; }
59+
else { spawn (x); } }
1060

1161
}
1262

0 commit comments

Comments
 (0)