From 734c3740c4ddccfbedf697edbd39021580fd51ce Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 4 May 2013 20:42:09 -0700 Subject: gras: implement force done input port option fixes #28 --- include/gras/block.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/gras/block.hpp b/include/gras/block.hpp index 8cb5f95..5f51acf 100644 --- a/include/gras/block.hpp +++ b/include/gras/block.hpp @@ -76,6 +76,22 @@ struct GRAS_API InputPortConfig * Default = 0. */ size_t preload_items; + + /*! + * Force this block done when input port is done. + * When the upstream feeding this port declares done, + * this block will mark done once upstream notifies. + * The primary usage is to modify the done logic + * for the purposes of unit test confiruability. + * + * If the force done option is false, the block will + * not mark done when this port's upstream is done. + * However, this block will mark done when all + * input ports are done, reguardless of this setting. + * + * Default = true. + */ + bool force_done; }; //! Configuration parameters for an output port -- cgit From 1b84453cc51b07eb9106bcd6731a321ff1924d74 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 5 May 2013 16:57:57 -0700 Subject: gras: added post input buffer/message/tag api calls This allows the user to post stuff to the input port from an external entity aka outside of the scheduler. resolves #86 --- include/gras/block.hpp | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/gras/block.hpp b/include/gras/block.hpp index 5f51acf..85a6ecc 100644 --- a/include/gras/block.hpp +++ b/include/gras/block.hpp @@ -202,15 +202,22 @@ struct GRAS_API Block : Element */ virtual void propagate_tags(const size_t which_input, const TagIter &iter); + /*! + * Send a tag to the given input port on this block. + * This is a thread-safe way for external scheduler + * entities to post tags into the input of a block. + * \param which_input an input port on this block + * \param tag the tag to post to the input port + */ + void post_input_tag(const size_t which_input, const Tag &tag); /******************************************************************* * Deal with message passing ******************************************************************/ /*! - * Post output message convenience routine. * Send a message to the downstream on the given output port. - * The underlying implementation is a tag with an offset of 0. + * Messages are naturally asynchronous to stream and tag data. * * \param which_output the index of the output port * \param msg the message object to pass downstream @@ -230,6 +237,15 @@ struct GRAS_API Block : Element */ PMCC pop_input_msg(const size_t which_input); + /*! + * Send a message to the given input port on this block. + * This is a thread-safe way for external scheduler + * entities to post messages into the input of a block. + * \param which_input an input port on this block + * \param msg the message to post to the input port + */ + void post_input_msg(const size_t which_input, const PMCC &tag); + /******************************************************************* * The property interface: * Provides polymorphic, thread-safe access to block properties. @@ -372,6 +388,10 @@ struct GRAS_API Block : Element */ void mark_done(void); + /******************************************************************* + * Direct buffer access API + ******************************************************************/ + /*! * Get access to the underlying reference counted input buffer. * This is the same buffer pointed to by input_items[which]. @@ -422,6 +442,20 @@ struct GRAS_API Block : Element */ void post_output_buffer(const size_t which_output, const SBuffer &buffer); + /*! + * Post a buffer to the given input port on this block. + * This is a thread-safe way for external scheduler + * entities to post buffers into the input of a block. + * + * \param which_input an input port on this block + * \param buffer the buffer to post to the input port + */ + void post_input_buffer(const size_t which_input, const SBuffer &buffer); + + /******************************************************************* + * Scheduler notification API + ******************************************************************/ + /*! * Overload notify_active to get called when block becomes active. * This will be called when the TopBlock start/run API call executes. @@ -443,6 +477,10 @@ struct GRAS_API Block : Element */ virtual void notify_topology(const size_t num_inputs, const size_t num_outputs); + /******************************************************************* + * routines related to affinity and allocation + ******************************************************************/ + /*! * Set if the work call should be interruptible by stop(). * Some work implementations block with the expectation of @@ -452,10 +490,6 @@ struct GRAS_API Block : Element */ void set_interruptible_work(const bool enb); - /******************************************************************* - * routines related to affinity and allocation - ******************************************************************/ - /*! * Set the node affinity of this block. * This call affects how output buffers are allocated. -- cgit