[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / openmp / libomptarget / plugins / remote / server / OffloadingServer.cpp
blob55c4c31fd5624e37f07a24f42537b12ce1b14e75
1 //===------------- OffloadingServer.cpp - Server Application --------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Offloading server for remote host.
11 //===----------------------------------------------------------------------===//
13 #include <future>
14 #include <grpcpp/server.h>
15 #include <grpcpp/server_builder.h>
16 #include <iostream>
17 #include <thread>
19 #include "Server.h"
21 using grpc::Server;
22 using grpc::ServerBuilder;
24 std::promise<void> ShutdownPromise;
26 int main() {
27 ClientManagerConfigTy Config;
29 RemoteOffloadImpl Service(Config.MaxSize, Config.BlockSize);
31 ServerBuilder Builder;
32 Builder.AddListeningPort(Config.ServerAddresses[0],
33 grpc::InsecureServerCredentials());
34 Builder.RegisterService(&Service);
35 Builder.SetMaxMessageSize(INT_MAX);
36 std::unique_ptr<Server> Server(Builder.BuildAndStart());
37 if (getDebugLevel())
38 std::cerr << "Server listening on " << Config.ServerAddresses[0]
39 << std::endl;
41 auto WaitForServer = [&]() { Server->Wait(); };
43 std::thread ServerThread(WaitForServer);
45 auto ShutdownFuture = ShutdownPromise.get_future();
46 ShutdownFuture.wait();
47 Server->Shutdown();
48 ServerThread.join();
50 return 0;