Implement pthread-based actor runtime with mailbox queuing#41
Open
Implement pthread-based actor runtime with mailbox queuing#41
Conversation
Replace no-op actor stubs in the C backend with real implementations: - Add pthread.h include for mutex/condvar support - Add riina_actor_type_t registry for actor declarations - Add riina_actor_t struct with ring buffer mailbox (256 slots), pthread_mutex_t, pthread_cond_t, and thread handle - riina_actor_decl: stores handler + init_state in type registry - riina_actor_spawn: initializes actor struct, mutex, condvar - riina_actor_send: mutex-protected ring buffer enqueue with condvar signal - riina_actor_recv: returns current actor state - Add 6 new tests verifying pthread includes, struct definitions, spawn/send/recv code generation https://claude.ai/code/session_01XLbQ6A6N4cKbjXDJ1iaDTU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement a complete actor runtime system using POSIX threads (pthread), replacing stub implementations with functional mailbox-based message passing. Actors now have proper state management, thread synchronization primitives, and a ring-buffer mailbox for message queuing.
Changes
#include <pthread.h>to generated C code headersriina_actor_type_tstruct to store actor type metadata (init state and handler)riina_actor_tstruct with full runtime state: actor ID, state, handler, ring-buffer mailbox, pthread mutex, condition variable, and thread handleriina_actor_decl()to register actor types in a global type registry and return type IDriina_actor_spawn()to create actor instances with initialized pthread synchronization primitivesriina_actor_send()with mutex-protected ring-buffer mailbox enqueuing and condition variable signalingriina_actor_recv()to return current actor stateType
Testing
test_emit_actor_pthread_include— verifies pthread header inclusiontest_emit_actor_struct_definition— verifies actor struct and synchronization primitivestest_emit_actor_spawn— verifies mutex/condition initialization on spawntest_emit_actor_send_mailbox— verifies mailbox ring-buffer and lockingtest_emit_actor_recv_returns_state— verifies state retrievaltest_emit_actor_decl_stores_type— verifies type registry storageChecklist
unsafecode in Rust (C code generation only)https://claude.ai/code/session_01XLbQ6A6N4cKbjXDJ1iaDTU