drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.45k stars 1.1k forks source link

call helloworld example from other tabs in browser not response!!!! #1799

Closed bnadem closed 4 months ago

bnadem commented 1 year ago

i have add function f3 inside registerHandler function app().registerHandler( "/", [](const HttpRequestPtr &, std::function<void(const HttpResponsePtr &)> &&callback) { auto resp = HttpResponse::newHttpResponse(); resp->setBody("Hello, World!"); callback(resp); f3(); }, {Get}); this function is only test , that take time execution : void f3() { for( long i = 1; i <= 100000000; ++i ) { std::cout<<"test"<<'\n'; } }

when i run ./helloword program work for first time in Browser but when i want new tabs im Browser, no response from Server, while he take time for response!!!! one solution call new Thread passing function f3, i search other alternative solution !!!

an-tao commented 1 year ago

Please refer to the article https://github.com/drogonframework/drogon/wiki/ENG-FAQ-1-Understanding-drogon-threading-model