Files
praxisandClaude Fable 5.2 8e02dccb86 In-client stack: transport, session lifecycle and engine bridge
175 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

42 lines
2.1 KiB
C

#include "poll_coordinator.private.h"
static int valid(const struct GwPollCoordinator *config) {
return config && config->abi == 1 && config->size == sizeof(*config) &&
config->host && config->frame_host_slot && config->frame_callback &&
config->frame_command && config->frame_completed &&
config->frame_initialize_status && config->frame_error &&
config->region.primary_thread == GetCurrentThreadId();
}
int gw_poll_coordinator_on_owned_input(const struct GwPollCoordinator *config,
struct GwPollOwnerSnapshot *snapshot) {
int result;
if (!valid(config) || !snapshot) return GW_POLL_REFUSED_LAYOUT;
if (InterlockedCompareExchange(config->frame_completed, 0, 0) != 0 ||
InterlockedCompareExchange(config->frame_command, 0, 0) != 0 ||
InterlockedCompareExchange(config->frame_error, 0, 0) != 0)
return GW_POLL_REFUSED_STATE;
result = gw_poll_bind_once(&config->region, config->host,
config->frame_host_slot, config->frame_callback);
if (result != GW_POLL_BOUND) return result;
return gw_poll_owner_snapshot(&config->region, snapshot);
}
int gw_poll_coordinator_frame_admitted(const struct GwPollCoordinator *config,
const struct GwPollOwnerSnapshot *snapshot) {
struct GwPollOwnerSnapshot current;
if (!valid(config) || !snapshot ||
gw_poll_owner_snapshot(&config->region, &current) != GW_POLL_BOUND ||
current.owner != snapshot->owner ||
current.clone_vtable != snapshot->clone_vtable ||
current.generation != snapshot->generation ||
current.primary_thread != snapshot->primary_thread ||
*config->frame_host_slot != config->host ||
InterlockedCompareExchange(config->frame_completed, 1, 1) != 1 ||
InterlockedCompareExchange(config->frame_initialize_status, 0, 0) != 0 ||
InterlockedCompareExchange(config->frame_error, 0, 0) != 0 ||
InterlockedCompareExchange(config->frame_command, 2, 2) != 2)
return 0;
return 1;
}