summaryrefslogtreecommitdiff
path: root/lib/block_props.cpp
diff options
context:
space:
mode:
authorJosh Blum2013-07-09 23:38:50 -0700
committerJosh Blum2013-07-09 23:38:50 -0700
commitc1f3f2df1d859937f26770d24fe464b150251251 (patch)
tree7179c280a73d46b413458c0cc0b70841fa9c9a0b /lib/block_props.cpp
parent8c3ccbe2445a86678d87d03f6626881a2fddc7d5 (diff)
downloadsandhi-c1f3f2df1d859937f26770d24fe464b150251251.tar.gz
sandhi-c1f3f2df1d859937f26770d24fe464b150251251.tar.bz2
sandhi-c1f3f2df1d859937f26770d24fe464b150251251.zip
gras: rename props files to calls (for callable work)
Diffstat (limited to 'lib/block_props.cpp')
-rw-r--r--lib/block_props.cpp84
1 files changed, 0 insertions, 84 deletions
diff --git a/lib/block_props.cpp b/lib/block_props.cpp
deleted file mode 100644
index 9a374f1..0000000
--- a/lib/block_props.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
-
-#include "element_impl.hpp"
-#include <gras/block.hpp>
-
-using namespace gras;
-
-/***********************************************************************
- * The actual thread-safe implementation of property handling
- **********************************************************************/
-void BlockActor::handle_callable(
- const CallableMessage &message,
- const Theron::Address from
-)
-{
- //setup reply
- CallableMessage reply;
- reply.key = message.key;
-
- //call into the handler overload to do the property access
- try
- {
- reply.ret = data->block->_handle_call_ts(message.key, message.args);
- }
- catch (const std::exception &e)
- {
- reply.error = e.what();
- }
- catch (...)
- {
- reply.error = "unknown error";
- }
-
- //send the reply
- this->Send(reply, from); //ACK
-
- //work could have been skipped by a high prio msg
- //forcefully kick the task to recheck in a new call
- this->Send(SelfKickMessage(), this->GetAddress());
-}
-
-PMCC Block::_handle_call_ts(const std::string &key, const PMCC &args)
-{
- //got here, so we call the base class unless this got overloaded
- return Callable::_handle_call(key, args);
-}
-
-/***********************************************************************
- * A special receiver to handle the property access result
- **********************************************************************/
-struct CallableReceiver : Theron::Receiver
-{
- CallableReceiver(void)
- {
- this->RegisterHandler(this, &CallableReceiver::handle_callable);
- }
-
- void handle_callable(const CallableMessage &msg, const Theron::Address)
- {
- this->message = msg;
- }
-
- CallableMessage message;
-};
-
-/***********************************************************************
- * Handle the get and set calls from the user's call-stack
- **********************************************************************/
-PMCC Block::_handle_call(const std::string &key, const PMCC &args)
-{
- CallableReceiver receiver;
- CallableMessage message;
- boost::shared_ptr<BlockActor> actor = (*this)->block_actor;
- message.prio_token = actor->prio_token;
- message.key = key;
- message.args = args;
- actor->GetFramework().Send(message, receiver.GetAddress(), actor->GetAddress());
- receiver.Wait();
- if (not receiver.message.error.empty())
- {
- throw std::runtime_error(receiver.message.error);
- }
- return receiver.message.ret;
-}