From 1ed1164d55f4258cf47a9e0f7f196cc2be345de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dziuba?= Date: Thu, 26 Sep 2024 08:57:43 +0200 Subject: [PATCH] refactor: update pandio --- .gitmodules | 6 +-- CMakeLists.txt | 14 +++---- README.md | 3 +- core/io.cc | 14 +++---- core/js_internals.h | 1 - core/main.cc | 2 - core/runtime.cc | 34 +++++------------ core/tcp.cc | 89 +++++++++++++++++++++++---------------------- core/timers.cc | 22 +++++------ deps/luxio | 1 - deps/pandio | 1 + sample.mjs | 4 -- v8.cmake | 18 +++++---- 13 files changed, 94 insertions(+), 115 deletions(-) delete mode 160000 deps/luxio create mode 160000 deps/pandio diff --git a/.gitmodules b/.gitmodules index 4eafcf01..80dcc321 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "luxio"] - path = deps/luxio - url = https://github.com/michaldziuba03/luxio +[submodule "pandio"] + path = deps/pandio + url = https://github.com/pandland diff --git a/CMakeLists.txt b/CMakeLists.txt index a7d9ced6..d9f6f894 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,27 +9,25 @@ add_definitions(-DV8_ENABLE_SANDBOX=1 -DV8_COMPRESS_POINTERS=1) add_executable(pand core/main.cc) -target_include_directories(pand SYSTEM - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/deps/v8/include) - target_include_directories(pand PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/deps/luxio/src + ${CMAKE_CURRENT_SOURCE_DIR}/deps/v8/include PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/deps/swcc/include) +# Add pandio library +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/deps/pandio pandio_build) + target_link_directories(pand PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/deps/v8/out.gn/x64.release.sample/obj PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/deps/luxio/build - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/deps/swcc/target/release) + target_link_libraries(pand swcc - luxio + pandio v8_libplatform v8_monolith pthread diff --git a/README.md b/README.md index d1610c46..3e013841 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,11 @@ You need to download v8 as dependency and it will take reasonable amount of time ```sh # Download v8 and build cmake -P v8.cmake + +# Build our actual project mkdir build cd build -# Build our actual project cmake .. cmake --build . ``` diff --git a/core/io.cc b/core/io.cc index cb253a8c..51749b99 100644 --- a/core/io.cc +++ b/core/io.cc @@ -1,22 +1,22 @@ #pragma once -#include +#include namespace runtime { -/* IO singleton - manages actuall event loop */ +/* IO singleton - manages actual event loop */ class IO { static IO *instance_; public: - lx_io_t *ctx; + pd_io_t *ctx; - IO(lx_io_t *ctx): ctx(ctx) {} + IO(pd_io_t *ctx): ctx(ctx) {} ~IO() { delete ctx; } static void create() { - lx_io_t *ctx = new lx_io_t; - lx_init(ctx); + pd_io_t *ctx = new pd_io_t; + pd_io_init(ctx); IO:instance_ = new IO(ctx); } @@ -25,7 +25,7 @@ class IO { } inline void run() { - lx_run(this->ctx); + pd_io_run(this->ctx); } }; diff --git a/core/js_internals.h b/core/js_internals.h index a7c51699..88cc2ed3 100644 --- a/core/js_internals.h +++ b/core/js_internals.h @@ -4,7 +4,6 @@ #include #include -#include std::unordered_map> js_internals = { {"std:assert", { 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x20, 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x64, 0x73, 0x20, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x6f, 0x72, 0x28, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x73, 0x75, 0x70, 0x65, 0x72, 0x28, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x3d, 0x20, 0x27, 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x27, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x7d, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x73, 0x73, 0x65, 0x72, 0x74, 0x28, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 0x72, 0x6f, 0x77, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x28, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x7c, 0x7c, 0x20, 0x22, 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x7d, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x73, 0x73, 0x65, 0x72, 0x74, 0x53, 0x74, 0x72, 0x69, 0x63, 0x74, 0x45, 0x71, 0x75, 0x61, 0x6c, 0x28, 0x61, 0x63, 0x74, 0x75, 0x61, 0x6c, 0x2c, 0x20, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x2c, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x69, 0x73, 0x28, 0x61, 0x63, 0x74, 0x75, 0x61, 0x6c, 0x2c, 0x20, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 0x72, 0x6f, 0x77, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x28, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x7c, 0x7c, 0x20, 0x22, 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, 0x20, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x20, 0x65, 0x71, 0x75, 0x61, 0x6c, 0x20, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x22, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x7d, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x73, 0x73, 0x65, 0x72, 0x74, 0x54, 0x68, 0x72, 0x6f, 0x77, 0x73, 0x28, 0x66, 0x75, 0x6e, 0x63, 0x2c, 0x20, 0x65, 0x72, 0x72, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x20, 0x3d, 0x20, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x2c, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x74, 0x72, 0x79, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x20, 0x63, 0x61, 0x74, 0x63, 0x68, 0x20, 0x28, 0x65, 0x72, 0x72, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x65, 0x72, 0x72, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x6f, 0x66, 0x20, 0x65, 0x72, 0x72, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x74, 0x68, 0x72, 0x6f, 0x77, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x28, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x7c, 0x7c, 0x20, 0x22, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x64, 0x6f, 0x65, 0x73, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x74, 0x68, 0x72, 0x6f, 0x77, 0x20, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x29, 0x3b, 0x0a, 0x7d, 0x0a }}, diff --git a/core/main.cc b/core/main.cc index 98129b4e..9859061e 100644 --- a/core/main.cc +++ b/core/main.cc @@ -1,7 +1,5 @@ #include -#include #include - #include "runtime.cc" int main(int argc, char* argv[]) { diff --git a/core/runtime.cc b/core/runtime.cc index 148e7d10..b2aa91ee 100644 --- a/core/runtime.cc +++ b/core/runtime.cc @@ -1,9 +1,10 @@ #include #include #include -#include +#include #include "loader.cc" +#include "pandio/core.h" #include "timers.cc" #include "io.cc" #include "tcp.cc" @@ -64,12 +65,13 @@ class Runtime { } void start(const char *entryfile, int argc, char* argv[]) { + IO::create(); + pd_io_t *ctx = IO::get()->ctx; + v8::HandleScope handle_scope(isolate); v8::Local global = v8::ObjectTemplate::New(isolate); std::string entrypath = fs::absolute(entryfile).string(); - IO::create(); - lx_io_t *ctx = IO::get()->ctx; v8::Local runtime_template = v8::ObjectTemplate::New(isolate); Runtime::initialize(runtime_template, isolate); @@ -91,8 +93,8 @@ class Runtime { loader.execute(isolate, context, "std:bootstrap"); loader.execute(isolate, context, entrypath); - std::thread memory_monitor(MonitorMemoryUsage, isolate); - memory_monitor.detach(); + //std::thread memory_monitor(MonitorMemoryUsage, isolate); + //memory_monitor.detach(); IO::get()->run(); } @@ -132,11 +134,7 @@ class Runtime { } static int get_pid() { - #if defined(_WIN32) || defined(_WIN64) - return GetCurrentProcessId(); - #else - return getpid(); - #endif + return pd_getpid(); } static void cwd(const v8::FunctionCallbackInfo &args) { @@ -152,21 +150,7 @@ class Runtime { } static const char *get_platform() { - #if defined(_WIN32) || defined(_WIN64) - return "win32"; - #elif defined(__APPLE__) || defined(__MACH__) - return "darwin"; - #elif defined(__linux__) - return "linux"; - #elif defined(__FreeBSD__) - return "freebsd"; - #elif defined(__OpenBSD__) - return "openbsd"; - #elif defined(__unix__) - return "unix"; - #else - return "unknown"; - #endif + return pd_get_platform(); } static void env(const v8::FunctionCallbackInfo &args) { diff --git a/core/tcp.cc b/core/tcp.cc index 50fe3075..dddb75c0 100644 --- a/core/tcp.cc +++ b/core/tcp.cc @@ -1,7 +1,8 @@ #pragma once +#include #include -#include +#include #include #include @@ -12,14 +13,14 @@ namespace runtime { class TcpStream { public: - lx_connection_t *conn; - lx_timer_t timeout; + pd_tcp_t conn; + pd_timer_t timeout; bool paused = false; v8::Persistent obj; TcpStream(v8::Isolate *isolate, v8::Local obj) { this->obj.Reset(isolate, obj); - lx_timer_init(IO::get()->ctx, &this->timeout); + pd_timer_init(IO::get()->ctx, &this->timeout); this->timeout.data = this; } @@ -73,16 +74,16 @@ class TcpStream { TcpStream *stream = static_cast(args.This()->GetAlignedPointerFromInternalField(0)); char *buf = strdup(*str); - lx_write_t *write_op = lx_write_alloc(buf, str.length()); - write_op->data = stream; - lx_write(write_op, stream->conn, TcpStream::handle_write); + pd_write_t *write_op = new pd_write_t; + pd_write_init(write_op, buf, str.length(), TcpStream::handle_write); + pd_tcp_write(&stream->conn, write_op); } static void close(const v8::FunctionCallbackInfo &args) { assert(args.Length() == 0); TcpStream *stream = static_cast(args.This()->GetAlignedPointerFromInternalField(0)); - lx_close(stream->conn); + pd_tcp_close(&stream->conn); } static void set_timeout(const v8::FunctionCallbackInfo &args) { @@ -98,12 +99,12 @@ class TcpStream { TcpStream *stream = static_cast(args.This()->GetAlignedPointerFromInternalField(0)); if (timeout == 0) { - lx_timer_stop(&stream->timeout); + pd_timer_stop(&stream->timeout); return; } - lx_timer_stop(&stream->timeout); - lx_timer_start(&stream->timeout, TcpStream::handle_timeout, timeout); + pd_timer_stop(&stream->timeout); + pd_timer_start(&stream->timeout, TcpStream::handle_timeout, timeout); } static void pause(const v8::FunctionCallbackInfo &args) { @@ -112,7 +113,7 @@ class TcpStream { TcpStream *stream = static_cast(args.This()->GetAlignedPointerFromInternalField(0)); if (!stream->paused) { - lx_stop_reading(&stream->conn->event, stream->conn->fd); + pd_tcp_pause(&stream->conn); stream->paused = true; } } @@ -123,18 +124,19 @@ class TcpStream { TcpStream *stream = static_cast(args.This()->GetAlignedPointerFromInternalField(0)); if (stream->paused) { - lx_set_read_event(&stream->conn->event, stream->conn->fd); + pd_tcp_resume(&stream->conn); stream->paused = false; } } /* handlers for event loop */ - static void handle_write(lx_write_t *write_op, int status) { - free((void*)write_op->buf); - free(write_op); + static void handle_write(pd_write_t *write_op, int status) { + free((void*)write_op->data.buf); + delete write_op; } - static void handle_data(lx_connection_t *conn) { + static void handle_data(pd_tcp_t *conn, char *buf, size_t size) { + printf("Status: %ld\n", size); fflush(stdout); TcpStream *stream = static_cast(conn->data); v8::Isolate *isolate = v8::Isolate::GetCurrent(); @@ -147,33 +149,26 @@ class TcpStream { return; } - char buf[1024]; - ssize_t res = recv(conn->fd, buf, 1024, 0); - if (res <= 0) { - lx_close(conn); - return; - } - - v8::Local args[1] = {v8::String::NewFromUtf8(isolate, buf, v8::NewStringType::kNormal, res).ToLocalChecked()}; + v8::Local args[1] = {v8::String::NewFromUtf8(isolate, buf, v8::NewStringType::kNormal, size).ToLocalChecked()}; callback->Call(context, v8::Undefined(isolate), 1, args).ToLocalChecked(); } - static void handle_close(lx_connection_t *conn) { + static void handle_close(pd_tcp_t *conn) { v8::Isolate *isolate = v8::Isolate::GetCurrent(); v8::HandleScope handle_scope(isolate); v8::Local context = isolate->GetCurrentContext(); TcpStream *stream = static_cast(conn->data); - lx_timer_stop(&stream->timeout); + pd_timer_stop(&stream->timeout); v8::Local callback = stream->obj.Get(isolate)->Get(context, v8_symbol(isolate, "onclose")).ToLocalChecked().As(); callback->Call(context, v8::Undefined(isolate), 0, {}).ToLocalChecked(); - delete stream; + //delete stream; } - static void handle_timeout(lx_timer_t *timer) { + static void handle_timeout(pd_timer_t *timer) { TcpStream *stream = static_cast(timer->data); - lx_close(stream->conn); + pd_tcp_close(&stream->conn); } }; @@ -181,6 +176,7 @@ v8::Persistent TcpStream::streamConstructor; class TcpServer { v8::Global callback; + pd_tcp_server_t handle; int port; static const int64_t kDefaultTimeout = 120 * 1000; @@ -204,31 +200,36 @@ class TcpServer { server->callback.Reset(isolate, callback); server->port = port; - lx_listener_t *l = lx_listen(IO::get()->ctx, port, TcpServer::handle_accept); - l->data = server; + pd_tcp_server_init(IO::get()->ctx, &server->handle); + server->handle.data = server; + int status = pd_tcp_listen(&server->handle, port, TcpServer::handle_accept); + if (status < 0) { + printf("Something went wrong..."); + } } - static void handle_accept(lx_connection_t *conn) { - TcpServer *server = static_cast(conn->listener->data); + static void handle_accept(pd_tcp_server_t *handle, pd_socket_t socket, int status) { + TcpServer *server = static_cast(handle->data); v8::Isolate *isolate = v8::Isolate::GetCurrent(); v8::HandleScope handle_scope(isolate); v8::Local context = isolate->GetCurrentContext(); v8::Local callback = server->callback.Get(isolate); - if (callback.IsEmpty()) { - lx_close(conn); - return; - } - v8::Local cons = v8::Local::New(isolate, TcpStream::streamConstructor); v8::Local tcpStreamWrap = cons->NewInstance(context).ToLocalChecked(); TcpStream *stream = static_cast(tcpStreamWrap->GetAlignedPointerFromInternalField(0)); - stream->conn = conn; - lx_timer_start(&stream->timeout, TcpStream::handle_timeout, TcpServer::kDefaultTimeout); - conn->data = (void*)stream; - conn->onclose = TcpStream::handle_close; - conn->ondata = TcpStream::handle_data; + pd_tcp_init(handle->ctx, &stream->conn); + pd_tcp_accept(&stream->conn, socket); + pd_timer_start(&stream->timeout, TcpStream::handle_timeout, TcpServer::kDefaultTimeout); + stream->conn.data = (void*)stream; + stream->conn.on_close = TcpStream::handle_close; + stream->conn.on_data = TcpStream::handle_data; + + if (callback.IsEmpty()) { + pd_tcp_close(&stream->conn); + return; + } v8::Local args[1] = {tcpStreamWrap}; callback->Call(context, v8::Undefined(isolate), 1, args).ToLocalChecked(); diff --git a/core/timers.cc b/core/timers.cc index 8cd3cc49..bb238855 100644 --- a/core/timers.cc +++ b/core/timers.cc @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -15,12 +15,12 @@ typedef int64_t TimerId; struct TimerWrap { TimerId id; TimerType type; - lx_timer_t handle; + pd_timer_t handle; v8::Global callback; }; class Timers { - lx_io_t *ctx; + pd_io_t *ctx; TimerId ids = 1; std::unordered_map active_timers; @@ -30,9 +30,9 @@ class Timers { protected: static Timers *instance_; - Timers(lx_io_t *ctx): ctx(ctx) {} + Timers(pd_io_t *ctx): ctx(ctx) {} public: - static void initialize(lx_io_t *ctx) { + static void initialize(pd_io_t *ctx) { Timers::instance_ = new Timers(ctx); } @@ -45,10 +45,10 @@ class Timers { timer->id = get_id(); timer->callback.Reset(v8::Isolate::GetCurrent(), callback); timer->type = TIMEOUT; - lx_timer_init(ctx, &timer->handle); + pd_timer_init(ctx, &timer->handle); timer->handle.data = timer; - lx_timer_start(&timer->handle, handle_timer, timeout); + pd_timer_start(&timer->handle, handle_timer, timeout); active_timers[timer->id] = std::move(timer); return timer->id; @@ -59,10 +59,10 @@ class Timers { timer->id = get_id(); timer->callback.Reset(v8::Isolate::GetCurrent(), callback); timer->type = INTERVAL; - lx_timer_init(ctx, &timer->handle); + pd_timer_init(ctx, &timer->handle); timer->handle.data = timer; - lx_timer_repeat(&timer->handle, handle_timer, interval); + pd_timer_repeat(&timer->handle, handle_timer, interval); active_timers[timer->id] = std::move(timer); return timer->id; @@ -78,12 +78,12 @@ class Timers { auto it = active_timers.find(id); if (it != active_timers.end()) { - lx_timer_stop(&it->second->handle); + pd_timer_stop(&it->second->handle); cleanup(it->second); } } - static void handle_timer(lx_timer_t *handle) { + static void handle_timer(pd_timer_t *handle) { TimerWrap *timer = static_cast(handle->data); v8::Isolate *isolate = v8::Isolate::GetCurrent(); v8::HandleScope handle_scope(isolate); diff --git a/deps/luxio b/deps/luxio deleted file mode 160000 index fd2cedda..00000000 --- a/deps/luxio +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fd2ceddafb1770a5af45fe1fa89c32ace9a17d08 diff --git a/deps/pandio b/deps/pandio new file mode 160000 index 00000000..38147cc7 --- /dev/null +++ b/deps/pandio @@ -0,0 +1 @@ +Subproject commit 38147cc78928f475f761fc09a8be1fda60c5b010 diff --git a/sample.mjs b/sample.mjs index 2047a502..7274dfff 100644 --- a/sample.mjs +++ b/sample.mjs @@ -26,10 +26,6 @@ console.log(`Url: ${import.meta.url}`); tcpListen((socket) => { console.log("Client connected"); - socket.pause(); - setTimeout(() => { - socket.resume(); - }, 10 * 1000) socket.read((chunk) => { console.log(`Received data`); diff --git a/v8.cmake b/v8.cmake index 82e944b7..83fa1912 100644 --- a/v8.cmake +++ b/v8.cmake @@ -16,14 +16,16 @@ endif() set(ENV{PATH} "$ENV{PATH}:${CMAKE_SOURCE_DIR}/deps/depot_tools") -message(STATUS "Running 'fetch v8'...") -execute_process( - COMMAND fetch v8 - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/deps - RESULT_VARIABLE result -) -if(result) - message(FATAL_ERROR "Failed to fetch v8.") +if(NOT EXISTS "${CMAKE_SOURCE_DIR}/deps/v8") + message(STATUS "Running 'fetch v8'...") + execute_process( + COMMAND fetch v8 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/deps + RESULT_VARIABLE result + ) + if(result) + message(FATAL_ERROR "Failed to fetch v8.") + endif() endif() message(STATUS "Running 'gclient sync'...")