euiko / duckdb-pgwire

DuckDB that quack with PostgreSQL protocol
MIT License
14 stars 1 forks source link

feat: asynchronous io #8

Closed euiko closed 3 months ago

euiko commented 3 months ago

This PR provides a major shift from blocking io to asynchronous one.

With these changes, there should be no more additional threads used to maintain the server and session.

Implementing async io would be quite tedious to maintain in C++17, without going into callback hell due to it lacks of support for coroutines.

This implementation uses JavaScript like Promise library, promise-cpp to keep it simple and nice with :

async_read(socket, buffer)
  .then([] (asio:error_code err, std::size_t len) {
    std::cout << "received " << len << " bytes" << std::endl;
  })