Merge commit 'c992cb4e42cc223f67ede0e48d7ff3f4947af0c6' as 'test/compatibility/C/uWebSockets'
This commit is contained in:
@ -0,0 +1,28 @@
|
||||
#include "App.h"
|
||||
#include <thread>
|
||||
#include <algorithm>
|
||||
|
||||
int main() {
|
||||
/* Overly simple hello world app, using multiple threads */
|
||||
std::vector<std::thread *> threads(std::thread::hardware_concurrency());
|
||||
|
||||
std::transform(threads.begin(), threads.end(), threads.begin(), [](std::thread *t) {
|
||||
return new std::thread([]() {
|
||||
|
||||
uWS::App().get("/*", [](auto *res, auto *req) {
|
||||
res->end("Hello world!");
|
||||
}).listen(3000, [](auto *token) {
|
||||
if (token) {
|
||||
std::cout << "Thread " << std::this_thread::get_id() << " listening on port " << 3000 << std::endl;
|
||||
} else {
|
||||
std::cout << "Thread " << std::this_thread::get_id() << " failed to listen on port 3000" << std::endl;
|
||||
}
|
||||
}).run();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
std::for_each(threads.begin(), threads.end(), [](std::thread *t) {
|
||||
t->join();
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user