tokio is needed by both temporal & gcloud pubsub, so make just one instance for the whole library, add init/shutdown functions for it exposed to C

This commit is contained in:
Grant Limberg 2025-08-07 11:28:22 -07:00
parent 4b3b847c7f
commit 837f15d01b
5 changed files with 65 additions and 16 deletions

View file

@ -26,6 +26,7 @@
#include <climits>
#include <iomanip>
#include <libpq-fe.h>
#include <rustybits.h>
#include <sstream>
using json = nlohmann::json;
@ -43,6 +44,8 @@ CV2::CV2(const Identity& myId, const char* path, int listenPort) : DB(), _pool()
auto span = tracer->StartSpan("cv2::CV2");
auto scope = tracer->WithActiveSpan(span);
rustybits::init_async_runtime();
fprintf(stderr, "CV2::CV2\n");
char myAddress[64];
_myAddressStr = myId.address().toString(myAddress);
@ -83,6 +86,8 @@ CV2::CV2(const Identity& myId, const char* path, int listenPort) : DB(), _pool()
CV2::~CV2()
{
rustybits::shutdown_async_runtime();
_run = 0;
std::this_thread::sleep_for(std::chrono::milliseconds(100));