#ifndef VGI_RPC_SHM_H#define VGI_RPC_SHM_H#include"vgi_rpc/batch.h"#ifdef __cplusplusextern"C"{#endif/* POSIX shared-memory side channel. One lockstep connection per segment. * Resolved batches own their buffers and remain valid after reuse or close. */structVgiShm;structVgiShmStats{uint64_tbatches_written,batches_read,bytes_written,bytes_read,inline_fallbacks;};intVgiShmCreate(int64_tsize,structVgiShm**,structArrowError*);intVgiShmAttach(constchar*name,int64_texpected_size,structVgiShm**,structArrowError*);voidVgiShmFree(structVgiShm*);/* Only the creator unlinks the segment. */constchar*VgiShmName(conststructVgiShm*);int64_tVgiShmSize(conststructVgiShm*);voidVgiShmGetStats(conststructVgiShm*,structVgiShmStats*);/* Threshold defaults to 128 KiB; zero routes every nonempty batch through SHM. */voidVgiShmSetThreshold(structVgiShm*,int64_tbytes);#ifdef __cplusplus}#endif#endif
#ifndef VGI_RPC_POOL_H#define VGI_RPC_POOL_H#include"vgi_rpc/client.h"#ifdef __cplusplusextern"C"{#endifstructVgiWorkerPool;structVgiWorkerLease;structVgiWorkerPoolOptions{/* One pool per subprocess command/configuration. Strings and argv are copied; * callback state and external-storage policy must outlive all leases. */structVgiClientOptionsclient;size_tmax_workers,max_idle;unsignedidle_timeout_ms,acquire_timeout_ms;};structVgiWorkerPoolStats{uint64_tspawns,reuses,discards,idle_evictions,timeouts;size_tactive,idle,waiting;};voidVgiWorkerPoolOptionsInit(structVgiWorkerPoolOptions*);intVgiWorkerPoolNew(conststructVgiWorkerPoolOptions*,structVgiWorkerPool**,structArrowError*);/* Thread-safe; a lease grants exclusive use of its client. Never free that client. * Exhausted pools wait up to acquire_timeout_ms. No RPC is automatically retried. */intVgiWorkerPoolAcquire(structVgiWorkerPool*,structVgiWorkerLease**,structArrowError*);structVgiClient*VgiWorkerLeaseClient(structVgiWorkerLease*);/* Application RPC errors may be reused after framing is drained. Broken peers, * abandoned streams, and explicitly discarded leases are terminated and reaped. */voidVgiWorkerLeaseRelease(structVgiWorkerLease*);voidVgiWorkerLeaseDiscard(structVgiWorkerLease*);voidVgiWorkerPoolGetStats(structVgiWorkerPool*,structVgiWorkerPoolStats*);voidVgiWorkerPoolClose(structVgiWorkerPool*);/* Wake waiters; reject new borrows. *//* Stop the idle reaper. Outstanding leases remain valid and keep the pool alive. * Do not begin any new pool operation after Free; existing waiters may finish. */voidVgiWorkerPoolFree(structVgiWorkerPool*);#ifdef __cplusplus}#endif#endif