summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/gras/block.hpp12
-rw-r--r--lib/block_allocator.cpp25
-rw-r--r--lib/gras_impl/messages.hpp4
-rw-r--r--lib/input_handlers.cpp4
4 files changed, 19 insertions, 26 deletions
diff --git a/include/gras/block.hpp b/include/gras/block.hpp
index 524ff00..1acc532 100644
--- a/include/gras/block.hpp
+++ b/include/gras/block.hpp
@@ -336,14 +336,12 @@ struct GRAS_API Block : Element
* //TODO code example
*
* \param which_output the output port index number
- * \param token the token for the buffer's returner
- * \param recommend_length the schedulers recommended length in bytes
+ * \param config holds token and recommended length
* \return a shared ptr to a new buffer queue object
*/
virtual BufferQueueSptr output_buffer_allocator(
const size_t which_output,
- const SBufferToken &token,
- const size_t recommend_length
+ const SBufferConfig &config
);
/*!
@@ -355,14 +353,12 @@ struct GRAS_API Block : Element
* input buffers which were actually allocated by this method.
*
* \param which_input the input port index number
- * \param token the token for the buffer's returner
- * \param recommend_length the schedulers recommended length in bytes
+ * \param config holds token and recommended length
* \return a shared ptr to a new buffer queue object
*/
virtual BufferQueueSptr input_buffer_allocator(
const size_t which_input,
- const SBufferToken &token,
- const size_t recommend_length
+ const SBufferConfig &config
);
};
diff --git a/lib/block_allocator.cpp b/lib/block_allocator.cpp
index 4c486ab..3f468cc 100644
--- a/lib/block_allocator.cpp
+++ b/lib/block_allocator.cpp
@@ -70,12 +70,18 @@ void BlockActor::handle_top_alloc(const TopAllocMessage &, const Theron::Address
SBufferDeleter deleter = boost::bind(&BlockActor::buffer_returner, this, i, _1);
SBufferToken token = SBufferToken(new SBufferDeleter(deleter));
- BufferQueueSptr queue = block_ptr->output_buffer_allocator(i, token, bytes);
+ SBufferConfig config;
+ config.memory = NULL;
+ config.length = bytes;
+ config.affinity = this->buffer_affinity;
+ config.token = token;
+
+ BufferQueueSptr queue = block_ptr->output_buffer_allocator(i, config);
this->output_queues.set_buffer_queue(i, queue);
InputAllocMessage message;
- message.token = SBufferToken(new SBufferDeleter(deleter));
- message.recommend_length = bytes;
+ message.config = config;
+ message.token = token;
this->post_downstream(i, message);
}
@@ -84,21 +90,14 @@ void BlockActor::handle_top_alloc(const TopAllocMessage &, const Theron::Address
BufferQueueSptr Block::output_buffer_allocator(
const size_t,
- const SBufferToken &token,
- const size_t recommend_length
+ const SBufferConfig &config
){
- SBufferConfig config;
- config.memory = NULL;
- config.length = recommend_length;
- config.affinity = (*this)->block->buffer_affinity;
- config.token = token;
- return BufferQueue::make_circ(config, THIS_MANY_BUFFERS);
+ return BufferQueue::make_pool(config, THIS_MANY_BUFFERS);
}
BufferQueueSptr Block::input_buffer_allocator(
const size_t,
- const SBufferToken &,
- const size_t
+ const SBufferConfig &
){
return BufferQueueSptr(); //null
}
diff --git a/lib/gras_impl/messages.hpp b/lib/gras_impl/messages.hpp
index b113e0d..57f308b 100644
--- a/lib/gras_impl/messages.hpp
+++ b/lib/gras_impl/messages.hpp
@@ -64,8 +64,8 @@ struct InputTokenMessage
struct InputAllocMessage
{
size_t index;
- SBufferToken token;
- size_t recommend_length;
+ SBufferConfig config;
+ SBufferToken token; //holds reference
};
struct InputCheckMessage
diff --git a/lib/input_handlers.cpp b/lib/input_handlers.cpp
index f6a81bc..4ca0bdf 100644
--- a/lib/input_handlers.cpp
+++ b/lib/input_handlers.cpp
@@ -66,9 +66,7 @@ void BlockActor::handle_input_alloc(const InputAllocMessage &message, const Ther
//handle the upstream block allocation request
OutputAllocMessage new_msg;
- new_msg.queue = block_ptr->input_buffer_allocator(
- index, message.token, message.recommend_length
- );
+ new_msg.queue = block_ptr->input_buffer_allocator(index, message.config);
if (new_msg.queue) this->post_upstream(index, new_msg);
}