summaryrefslogtreecommitdiff
path: root/lib/block_actor.cpp
diff options
context:
space:
mode:
authorJosh Blum2013-04-14 01:08:05 -0700
committerJosh Blum2013-04-14 01:08:05 -0700
commita83447f0b74231de3d4bc7554e0be40ae5c3857f (patch)
tree0ab08c0497f9675215f5cf83a9c3bb372c46452e /lib/block_actor.cpp
parentecbd0c699884e8da150cfdcab836b1ffd5487f67 (diff)
downloadsandhi-a83447f0b74231de3d4bc7554e0be40ae5c3857f.tar.gz
sandhi-a83447f0b74231de3d4bc7554e0be40ae5c3857f.tar.bz2
sandhi-a83447f0b74231de3d4bc7554e0be40ae5c3857f.zip
gras: yield policy env, and throw on bad value
Diffstat (limited to 'lib/block_actor.cpp')
-rw-r--r--lib/block_actor.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/block_actor.cpp b/lib/block_actor.cpp
index 2ab5049..750e52d 100644
--- a/lib/block_actor.cpp
+++ b/lib/block_actor.cpp
@@ -4,6 +4,7 @@
#include <gras_impl/block_actor.hpp>
#include <boost/thread/thread.hpp>
#include <Theron/Framework.h>
+#include <stdexcept>
using namespace gras;
@@ -14,6 +15,10 @@ ThreadPoolConfig::ThreadPoolConfig(void)
node_mask = 0;
processor_mask = 0xffffffff;
yield_strategy = "STRONG";
+
+ //environment variable override
+ const char * gras_yield = getenv("GRAS_YIELD");
+ if (gras_yield != NULL) yield_strategy = gras_yield;
}
/***********************************************************************
@@ -38,10 +43,12 @@ ThreadPool::ThreadPool(const ThreadPoolConfig &config)
config.processor_mask
);
- //if (config.yield_strategy == "BLOCKING") params.mYieldStrategy = Theron::YIELD_STRATEGY_BLOCKING;
- if (config.yield_strategy == "POLITE") params.mYieldStrategy = Theron::YIELD_STRATEGY_POLITE;
- if (config.yield_strategy == "STRONG") params.mYieldStrategy = Theron::YIELD_STRATEGY_STRONG;
- if (config.yield_strategy == "AGGRESSIVE") params.mYieldStrategy = Theron::YIELD_STRATEGY_AGGRESSIVE;
+ if (config.yield_strategy.empty()) params.mYieldStrategy = Theron::YIELD_STRATEGY_STRONG;
+ //else if (config.yield_strategy == "BLOCKING") params.mYieldStrategy = Theron::YIELD_STRATEGY_BLOCKING;
+ else if (config.yield_strategy == "POLITE") params.mYieldStrategy = Theron::YIELD_STRATEGY_POLITE;
+ else if (config.yield_strategy == "STRONG") params.mYieldStrategy = Theron::YIELD_STRATEGY_STRONG;
+ else if (config.yield_strategy == "AGGRESSIVE") params.mYieldStrategy = Theron::YIELD_STRATEGY_AGGRESSIVE;
+ else throw std::runtime_error("gras::ThreadPoolConfig yield_strategy unknown: " + config.yield_strategy);
this->reset(new Theron::Framework(Theron::Framework::Parameters(params)));
}