summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosh Blum2012-09-30 02:48:22 -0700
committerJosh Blum2012-09-30 02:48:22 -0700
commit8e224b5da13783bfd89eccd356b030146d02396d (patch)
tree1afb5d0221610f8fdcaa7041e61491e2027dcb3b /lib
parentf5d9f2b631049f49b9008a95df56d5cc1ad11335 (diff)
downloadsandhi-8e224b5da13783bfd89eccd356b030146d02396d.tar.gz
sandhi-8e224b5da13783bfd89eccd356b030146d02396d.tar.bz2
sandhi-8e224b5da13783bfd89eccd356b030146d02396d.zip
created a bitset wrapper w/ all() routine
as it turns out ~ was making a new bitset and a malloc just make some common code to avoid the reuse
Diffstat (limited to 'lib')
-rw-r--r--lib/block_task.cpp2
-rw-r--r--lib/gras_impl/bitset.hpp37
-rw-r--r--lib/gras_impl/block_actor.hpp9
-rw-r--r--lib/gras_impl/input_buffer_queues.hpp6
-rw-r--r--lib/gras_impl/output_buffer_queues.hpp6
-rw-r--r--lib/input_handlers.cpp2
-rw-r--r--lib/output_handlers.cpp2
7 files changed, 50 insertions, 14 deletions
diff --git a/lib/block_task.cpp b/lib/block_task.cpp
index 5b1a667..d1ff52b 100644
--- a/lib/block_task.cpp
+++ b/lib/block_task.cpp
@@ -250,7 +250,7 @@ GRAS_FORCE_INLINE void BlockActor::conclusion(void)
{
//since nothing else is coming in, its safe to mark done
- if ((~this->inputs_done).none()) //no upstream providers
+ if (this->inputs_done.all()) //no upstream providers
{
if (not this->input_queues.all_ready() or this->forecast_fail)
{
diff --git a/lib/gras_impl/bitset.hpp b/lib/gras_impl/bitset.hpp
new file mode 100644
index 0000000..24bc2df
--- /dev/null
+++ b/lib/gras_impl/bitset.hpp
@@ -0,0 +1,37 @@
+//
+// Copyright 2012 Josh Blum
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with io_sig program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef INCLUDED_LIBGRAS_IMPL_BITSET_HPP
+#define INCLUDED_LIBGRAS_IMPL_BITSET_HPP
+
+#include <gnuradio/gras.hpp>
+#include <boost/dynamic_bitset.hpp>
+
+namespace gnuradio
+{
+
+//! Its just dynamic bitset w/ the handle all() routine
+struct BitSet : boost::dynamic_bitset<>
+{
+ GRAS_FORCE_INLINE bool all(void) const
+ {
+ return this->count() == this->size();
+ }
+};
+
+} //namespace gnuradio
+
+#endif /*INCLUDED_LIBGRAS_IMPL_BITSET_HPP*/
diff --git a/lib/gras_impl/block_actor.hpp b/lib/gras_impl/block_actor.hpp
index 60c730f..f321f22 100644
--- a/lib/gras_impl/block_actor.hpp
+++ b/lib/gras_impl/block_actor.hpp
@@ -17,17 +17,16 @@
#ifndef INCLUDED_LIBGRAS_IMPL_BLOCK_ACTOR_HPP
#define INCLUDED_LIBGRAS_IMPL_BLOCK_ACTOR_HPP
-
+#include <gras_impl/debug.hpp>
+#include <gras_impl/bitset.hpp>
#include <gnuradio/gras.hpp>
#include <gnuradio/block.hpp>
#include <Apology/Worker.hpp>
-#include <gras_impl/debug.hpp>
#include <gras_impl/token.hpp>
#include <gras_impl/messages.hpp>
#include <gras_impl/output_buffer_queues.hpp>
#include <gras_impl/input_buffer_queues.hpp>
#include <gras_impl/interruptible_thread.hpp>
-#include <boost/dynamic_bitset.hpp>
#include <vector>
#include <set>
@@ -144,8 +143,8 @@ struct BlockActor : Apology::Worker
//track the subscriber counts
std::vector<Token> input_tokens;
std::vector<Token> output_tokens;
- boost::dynamic_bitset<> inputs_done;
- boost::dynamic_bitset<> outputs_done;
+ BitSet inputs_done;
+ BitSet outputs_done;
std::set<Token> token_pool;
std::vector<SBufferToken> output_buffer_tokens;
diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp
index f69ba62..9b0df4a 100644
--- a/lib/gras_impl/input_buffer_queues.hpp
+++ b/lib/gras_impl/input_buffer_queues.hpp
@@ -18,9 +18,9 @@
#define INCLUDED_LIBGRAS_IMPL_INPUT_BUFFERS_HPP
#include <gras_impl/debug.hpp>
+#include <gras_impl/bitset.hpp>
#include <gras_impl/buffer_queue.hpp>
#include <gnuradio/sbuffer.hpp>
-#include <boost/dynamic_bitset.hpp>
#include <vector>
#include <queue>
#include <deque>
@@ -87,7 +87,7 @@ struct InputBufferQueues
GRAS_FORCE_INLINE bool all_ready(void) const
{
- return (~_bitset).none();
+ return _bitset.all();
}
void __prepare(const size_t i);
@@ -97,7 +97,7 @@ struct InputBufferQueues
_bitset.set(i, _enqueued_bytes[i] >= _reserve_bytes[i]);
}
- boost::dynamic_bitset<> _bitset;
+ BitSet _bitset;
std::vector<size_t> _enqueued_bytes;
std::vector<std::deque<SBuffer> > _queues;
std::vector<size_t> _history_bytes;
diff --git a/lib/gras_impl/output_buffer_queues.hpp b/lib/gras_impl/output_buffer_queues.hpp
index d484f3d..18eb551 100644
--- a/lib/gras_impl/output_buffer_queues.hpp
+++ b/lib/gras_impl/output_buffer_queues.hpp
@@ -17,7 +17,7 @@
#ifndef INCLUDED_LIBGRAS_IMPL_OUTPUT_BUFFER_QUEUES_HPP
#define INCLUDED_LIBGRAS_IMPL_OUTPUT_BUFFER_QUEUES_HPP
-#include <boost/dynamic_bitset.hpp>
+#include <gras_impl/bitset.hpp>
#include <vector>
#include <deque>
@@ -27,7 +27,7 @@ namespace gnuradio
template <typename T>
struct OutputBufferQueues
{
- boost::dynamic_bitset<> _bitset;
+ BitSet _bitset;
std::vector<std::deque<T> > _queues;
GRAS_FORCE_INLINE void resize(const size_t size)
@@ -90,7 +90,7 @@ struct OutputBufferQueues
GRAS_FORCE_INLINE bool all_ready(void) const
{
- return (~_bitset).none();
+ return _bitset.all();
}
GRAS_FORCE_INLINE size_t size(void) const
diff --git a/lib/input_handlers.cpp b/lib/input_handlers.cpp
index 461600f..193647d 100644
--- a/lib/input_handlers.cpp
+++ b/lib/input_handlers.cpp
@@ -57,7 +57,7 @@ void BlockActor::handle_input_check(const InputCheckMessage &message, const Ther
//an upstream block declared itself done, recheck the token
this->inputs_done.set(index, this->input_tokens[index].unique());
- if ((~this->inputs_done).none()) //no upstream providers
+ if (this->inputs_done.all()) //no upstream providers
{
if (not this->input_queues.all_ready())
{
diff --git a/lib/output_handlers.cpp b/lib/output_handlers.cpp
index fa01b51..5165b2a 100644
--- a/lib/output_handlers.cpp
+++ b/lib/output_handlers.cpp
@@ -48,7 +48,7 @@ void BlockActor::handle_output_check(const OutputCheckMessage &message, const Th
//a downstream block has declared itself done, recheck the token
this->outputs_done.set(index, this->output_tokens[index].unique());
- if ((~this->outputs_done).none()) //no downstream subscribers?
+ if (this->outputs_done.all()) //no downstream subscribers?
{
this->mark_done();
}