From 6b1444aa3918382aba127c16c671f045a3586e53 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 02:29:14 +0100 Subject: Common pipe replaced with sender/receiver functors. [#27] C library now only takes care of relaying data to/from functors, which must be provided by the wrapping application (in this case, a new python module named 'common.py'). --- include/common.h | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'include/common.h') diff --git a/include/common.h b/include/common.h index 7386a34..50ac563 100644 --- a/include/common.h +++ b/include/common.h @@ -2,17 +2,34 @@ * @file common.h * @author Paul Oliver * -* This module controls the 'common pipe', which is the FIFO file through which +* This module controls the common sender and receiver functors, through which * communication between different simulations can occur. By calling SEND, -* processes may output local instructions through the pipe. These instructions -* may then be read by processes running on a different simulation instance. +* processes may output local instructions through a network. These instructions +* may then be read by processes running on a different simulation somewhere +* else. */ #ifndef SALIS_COMMON_H #define SALIS_COMMON_H -void _sal_comm_init(string pipe); -void _sal_comm_quit(void); +/* Typedef sender functor type for easy python parsing. +*/ +typedef void (*Sender)(uint8 inst); + +/* Typedef receiver functor type for easy python parsing. +*/ +typedef uint8 (*Receiver)(void); + +/* Set sender functor. When unset, SEND instruction does nothing. +* @param sender Sender functor +*/ +SALIS_API void sal_comm_set_sender(Sender sender); + +/* Set receiver functor. When unset, RCVE instruction does nothing. +* @param receiver Receiver functor +*/ +SALIS_API void sal_comm_set_receiver(Receiver receiver); + void _sal_comm_send(uint8 inst); uint8 _sal_comm_receive(void); -- cgit v1.2.1