Giter Site home page Giter Site logo

异步http请求? about tbox HOT 3 OPEN

bethebest0622 avatar bethebest0622 commented on May 25, 2024
异步http请求?

from tbox.

Comments (3)

Issues-translate-bot avatar Issues-translate-bot commented on May 25, 2024

Bot detected the issue body's language is not English, translate it automatically.


Title: Asynchronous http request?

Hello, thanks for open source, I learned a lot.

There is currently a thorny problem. My program receives external input. Each input corresponds to an http request. The server response is relatively slow. Synchronous requests will cause the program io to block for 500ms. There may be other requests to process during these 500ms. Or other operations need to be performed, so I hope that the http request operation is asynchronous.

Asynchronous means that I hope that my http request function can return immediately. When the http request returns data (json will be returned after 500ms), the returned json data will be processed through the pre-registered callback.

The desired function signature is this:

void http_request(const std::string & request_url, const std::string & header, std::function<void<const rapidjson::Document>> & func) {
}

There has been some research before, but the coding power is insufficient and has not been solved. It should be implemented using coroutines + http network operations. I wonder if you can give me some guidance? grateful

ps. Pay more attention to performance and speed

from tbox.

waruqi avatar waruqi commented on May 25, 2024

那就用协程呗 https://github.com/tboox/tbox/blob/master/src/demo/coroutine/stream.c

from tbox.

Issues-translate-bot avatar Issues-translate-bot commented on May 25, 2024

Bot detected the issue body's language is not English, translate it automatically.


Then use coroutine https://github.com/tboox/tbox/blob/master/src/demo/coroutine/stream.c

from tbox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.