1 //===------------- OffloadingServer.cpp - Server Application --------------===//
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
7 //===----------------------------------------------------------------------===//
9 // Offloading server for remote host.
11 //===----------------------------------------------------------------------===//
14 #include <grpcpp/server.h>
15 #include <grpcpp/server_builder.h>
22 using grpc::ServerBuilder
;
24 std::promise
<void> ShutdownPromise
;
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());
38 std::cerr
<< "Server listening on " << Config
.ServerAddresses
[0]
41 auto WaitForServer
= [&]() { Server
->Wait(); };
43 std::thread
ServerThread(WaitForServer
);
45 auto ShutdownFuture
= ShutdownPromise
.get_future();
46 ShutdownFuture
.wait();