Loading...
Searching...
No Matches
ServeRpcServer.h File Reference
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  eonc
 RAII resource manager for the ARTn C library with global synchronization.

Typedefs

using eonc::ForceCallback
 Callback type for potential energy/force evaluation.
using ForceCallback
 Callback type for potential energy/force evaluation.

Functions

void eonc::startRpcServer (ForceCallback callback, const std::string &host, uint16_t port)
 Start a blocking Cap'n Proto RPC server using a force callback.
void eonc::startPooledRpcServer (std::vector< ForceCallback > pool, const std::string &host, uint16_t port)
 Start a blocking Cap'n Proto RPC server backed by a pool of force callbacks dispatched round-robin.
void startPooledRpcServer (std::vector< ForceCallback > pool, const std::string &host, uint16_t port)
 Start a blocking Cap'n Proto RPC server backed by a pool of force callbacks dispatched round-robin.
void startRpcServer (ForceCallback callback, const std::string &host, uint16_t port)
 Start a blocking Cap'n Proto RPC server using a force callback.

Typedef Documentation

◆ ForceCallback

Callback type for potential energy/force evaluation.

Flat-array interface that avoids any AtomMatrix type dependency, preventing collisions between eOn's Eigen-based AtomMatrix and rgpot's custom AtomMatrix.

Parameters
nAtomsNumber of atoms.
positionsFlat array [x1,y1,z1, x2,y2,z2, ...] (nAtoms*3).
atomicNrsAtomic numbers [Z1, Z2, ...] (nAtoms).
forcesOutput forces [Fx1,Fy1,Fz1, ...] (nAtoms*3).
energyOutput energy (single double).
boxSimulation cell flat 3x3 row-major (9 doubles).

Definition at line 36 of file ServeRpcServer.h.

Function Documentation

◆ startPooledRpcServer()

void eonc::startPooledRpcServer ( std::vector< ForceCallback > pool,
const std::string & host,
uint16_t port )

Start a blocking Cap'n Proto RPC server backed by a pool of force callbacks dispatched round-robin.

Parameters
poolVector of force callbacks (one per pool instance).
hostThe hostname to listen on.
portThe TCP port to listen on.

Definition at line 61 of file ServeRpcServer.cpp.

186 {
187 EONC_LOG_INFO("Starting pooled RPC gateway on {}:{} with {} instances", host,
188 port, pool.size());
189
190 capnp::EzRpcServer server(kj::heap<PooledCallbackPotImpl>(std::move(pool)),
191 host, port);
192
193 auto &waitScope = server.getWaitScope();
194 EONC_LOG_INFO("Gateway ready on port {}. Ctrl+C to stop.", port);
195 kj::NEVER_DONE.wait(waitScope);
196}
#define EONC_LOG_INFO(...)
Definition EonLogger.h:250

◆ startRpcServer()

void eonc::startRpcServer ( ForceCallback callback,
const std::string & host,
uint16_t port )

Start a blocking Cap'n Proto RPC server using a force callback.

Defined in a separate translation unit to avoid naming collision between eOn's class Potential and the capnp-generated Potential interface.

Parameters
callbackForce evaluation function.
hostThe hostname to listen on.
portThe TCP port to listen on.

Definition at line 50 of file ServeRpcServer.cpp.

104 {
105 EONC_LOG_INFO("Starting Cap'n Proto RPC server on {}:{}", host, port);
106
107 capnp::EzRpcServer server(kj::heap<CallbackPotImpl>(std::move(callback)),
108 host, port);
109
110 auto &waitScope = server.getWaitScope();
111 EONC_LOG_INFO("Server ready on port {}. Ctrl+C to stop.", port);
112 kj::NEVER_DONE.wait(waitScope);
113}