xo-reactor: prefer xo::bp spelling to xo::ref::brw
This commit is contained in:
parent
eccc50d2b9
commit
f9b7ab307a
9 changed files with 22 additions and 24 deletions
|
|
@ -30,7 +30,7 @@ namespace xo {
|
||||||
/* visit direct downstream consumers c[i] of this event processor.
|
/* visit direct downstream consumers c[i] of this event processor.
|
||||||
* call ep(c[i]) for each such consumer.
|
* call ep(c[i]) for each such consumer.
|
||||||
*/
|
*/
|
||||||
virtual void visit_direct_consumers(std::function<void (ref::brw<AbstractEventProcessor> ep)> const & fn) = 0;
|
virtual void visit_direct_consumers(std::function<void (bp<AbstractEventProcessor> ep)> const & fn) = 0;
|
||||||
|
|
||||||
/* write representation to stream */
|
/* write representation to stream */
|
||||||
virtual void display(std::ostream & os) const = 0;
|
virtual void display(std::ostream & os) const = 0;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ namespace xo {
|
||||||
if (reactor) {
|
if (reactor) {
|
||||||
if (is_priming) {
|
if (is_priming) {
|
||||||
/* reactor/simulator takes delivery/sequencing responsibility from here */
|
/* reactor/simulator takes delivery/sequencing responsibility from here */
|
||||||
reactor->notify_source_primed(ref::brw<ReactorSource>::from_native(this));
|
reactor->notify_source_primed(bp<ReactorSource>::from_native(this));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* if no reactor, deliver immediately */
|
/* if no reactor, deliver immediately */
|
||||||
|
|
@ -181,7 +181,7 @@ namespace xo {
|
||||||
virtual std::string const & name() const override { return name_; }
|
virtual std::string const & name() const override { return name_; }
|
||||||
virtual void set_name(std::string const & x) override { this->name_ = x; }
|
virtual void set_name(std::string const & x) override { this->name_ = x; }
|
||||||
|
|
||||||
virtual void visit_direct_consumers(std::function<void (ref::brw<AbstractEventProcessor> ep)> const & fn) override {
|
virtual void visit_direct_consumers(std::function<void (bp<AbstractEventProcessor> ep)> const & fn) override {
|
||||||
for (auto x : this->cb_set_)
|
for (auto x : this->cb_set_)
|
||||||
fn(x.fn_.borrow());
|
fn(x.fn_.borrow());
|
||||||
} /*visit_direct_consumers*/
|
} /*visit_direct_consumers*/
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ namespace xo {
|
||||||
|
|
||||||
// ----- inherited from Reactor -----
|
// ----- inherited from Reactor -----
|
||||||
|
|
||||||
virtual bool add_source(ref::brw<ReactorSource> src) override;
|
virtual bool add_source(bp<ReactorSource> src) override;
|
||||||
virtual bool remove_source(ref::brw<ReactorSource> src) override;
|
virtual bool remove_source(bp<ReactorSource> src) override;
|
||||||
virtual void notify_source_primed(ref::brw<ReactorSource> src) override;
|
virtual void notify_source_primed(bp<ReactorSource> src) override;
|
||||||
virtual std::uint64_t run_one() override;
|
virtual std::uint64_t run_one() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ namespace xo {
|
||||||
|
|
||||||
virtual std::string const & name() const override { return this->poly_sink_->name(); }
|
virtual std::string const & name() const override { return this->poly_sink_->name(); }
|
||||||
virtual void set_name(std::string const & x) override { this->poly_sink_->set_name(x); }
|
virtual void set_name(std::string const & x) override { this->poly_sink_->set_name(x); }
|
||||||
virtual void visit_direct_consumers(std::function<void (ref::brw<AbstractEventProcessor> ep)> const & fn) override {
|
virtual void visit_direct_consumers(std::function<void (bp<AbstractEventProcessor> ep)> const & fn) override {
|
||||||
this->poly_sink_->visit_direct_consumers(fn);
|
this->poly_sink_->visit_direct_consumers(fn);
|
||||||
}
|
}
|
||||||
virtual void display(std::ostream & os) const override {
|
virtual void display(std::ostream & os) const override {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace xo {
|
||||||
*
|
*
|
||||||
* returns true if source added; false if already present
|
* returns true if source added; false if already present
|
||||||
*/
|
*/
|
||||||
virtual bool add_source(ref::brw<ReactorSource> src) = 0;
|
virtual bool add_source(bp<ReactorSource> src) = 0;
|
||||||
|
|
||||||
/* remove source src from this reactor.
|
/* remove source src from this reactor.
|
||||||
* source must previously have been added by
|
* source must previously have been added by
|
||||||
|
|
@ -35,12 +35,12 @@ namespace xo {
|
||||||
*
|
*
|
||||||
* returns true if source removed; false if not present
|
* returns true if source removed; false if not present
|
||||||
*/
|
*/
|
||||||
virtual bool remove_source(ref::brw<ReactorSource> src) = 0;
|
virtual bool remove_source(bp<ReactorSource> src) = 0;
|
||||||
|
|
||||||
/* notification when non-primed source (source with no known events)
|
/* notification when non-primed source (source with no known events)
|
||||||
* becomes primed (source with at least one event)
|
* becomes primed (source with at least one event)
|
||||||
*/
|
*/
|
||||||
virtual void notify_source_primed(ref::brw<ReactorSource> src) = 0;
|
virtual void notify_source_primed(bp<ReactorSource> src) = 0;
|
||||||
|
|
||||||
/* dispatch one reactor event, borrowing the calling thread
|
/* dispatch one reactor event, borrowing the calling thread
|
||||||
* amount of work this represents is Source/Sink specific.
|
* amount of work this represents is Source/Sink specific.
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ namespace xo {
|
||||||
if (reactor) {
|
if (reactor) {
|
||||||
if (is_priming) {
|
if (is_priming) {
|
||||||
/* reactor/simulator takes responsibility for delivering events */
|
/* reactor/simulator takes responsibility for delivering events */
|
||||||
reactor->notify_source_primed(ref::brw<ReactorSource>::from_native(this));
|
reactor->notify_source_primed(bp<ReactorSource>::from_native(this));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* special case if no reactor: deliver immediately */
|
/* special case if no reactor: deliver immediately */
|
||||||
|
|
@ -225,7 +225,7 @@ namespace xo {
|
||||||
virtual std::string const & name() const override { return name_; }
|
virtual std::string const & name() const override { return name_; }
|
||||||
virtual void set_name(std::string const & x) override { this->name_ = x; }
|
virtual void set_name(std::string const & x) override { this->name_ = x; }
|
||||||
|
|
||||||
virtual void visit_direct_consumers(std::function<void (ref::brw<AbstractEventProcessor> ep)> const & fn) override {
|
virtual void visit_direct_consumers(std::function<void (bp<AbstractEventProcessor> ep)> const & fn) override {
|
||||||
|
|
||||||
for(auto x : this->cb_set_)
|
for(auto x : this->cb_set_)
|
||||||
fn(x.fn_.borrow());
|
fn(x.fn_.borrow());
|
||||||
|
|
@ -275,7 +275,7 @@ namespace xo {
|
||||||
if (reactor) {
|
if (reactor) {
|
||||||
if (is_priming) {
|
if (is_priming) {
|
||||||
/* reactor/simulator takes responsibility for delivering events */
|
/* reactor/simulator takes responsibility for delivering events */
|
||||||
reactor->notify_source_primed(ref::brw<ReactorSource>::from_native(this));
|
reactor->notify_source_primed(bp<ReactorSource>::from_native(this));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* if no reactor, deliver immediately */
|
/* if no reactor, deliver immediately */
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ namespace xo {
|
||||||
virtual std::string const & name() const override { return name_; }
|
virtual std::string const & name() const override { return name_; }
|
||||||
virtual void set_name(std::string const & x) override { name_ = x; }
|
virtual void set_name(std::string const & x) override { name_ = x; }
|
||||||
|
|
||||||
virtual void visit_direct_consumers(std::function<void (ref::brw<AbstractEventProcessor>)> const &) override {
|
virtual void visit_direct_consumers(std::function<void (bp<AbstractEventProcessor>)> const &) override {
|
||||||
/* *this is not an event source */
|
/* *this is not an event source */
|
||||||
} /*visit_direct_consumers*/
|
} /*visit_direct_consumers*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
using ref::brw;
|
|
||||||
using xo::tostr;
|
using xo::tostr;
|
||||||
using std::uint32_t;
|
using std::uint32_t;
|
||||||
|
|
||||||
|
|
@ -16,7 +15,7 @@ namespace xo {
|
||||||
* add to *m;
|
* add to *m;
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
map_network_helper(brw<AbstractEventProcessor> x,
|
map_network_helper(bp<AbstractEventProcessor> x,
|
||||||
uint32_t * tsort_ix,
|
uint32_t * tsort_ix,
|
||||||
std::unordered_map<AbstractEventProcessor*, uint32_t> * m)
|
std::unordered_map<AbstractEventProcessor*, uint32_t> * m)
|
||||||
{
|
{
|
||||||
|
|
@ -24,7 +23,7 @@ namespace xo {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto fn = [tsort_ix, m]
|
auto fn = [tsort_ix, m]
|
||||||
(brw<AbstractEventProcessor> ep)
|
(bp<AbstractEventProcessor> ep)
|
||||||
{
|
{
|
||||||
map_network_helper(ep, tsort_ix, m);
|
map_network_helper(ep, tsort_ix, m);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,13 @@
|
||||||
#include "PollingReactor.hpp"
|
#include "PollingReactor.hpp"
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
using ref::brw;
|
|
||||||
using std::size_t;
|
using std::size_t;
|
||||||
using std::uint64_t;
|
using std::uint64_t;
|
||||||
using std::int64_t;
|
using std::int64_t;
|
||||||
|
|
||||||
namespace reactor {
|
namespace reactor {
|
||||||
bool
|
bool
|
||||||
PollingReactor::add_source(brw<ReactorSource> src)
|
PollingReactor::add_source(bp<ReactorSource> src)
|
||||||
{
|
{
|
||||||
/* make sure src does not already appear in .source_v[] */
|
/* make sure src does not already appear in .source_v[] */
|
||||||
for(ReactorSourcePtr const & x : this->source_v_) {
|
for(ReactorSourcePtr const & x : this->source_v_) {
|
||||||
|
|
@ -28,7 +27,7 @@ namespace xo {
|
||||||
} /*add_source*/
|
} /*add_source*/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PollingReactor::remove_source(brw<ReactorSource> src)
|
PollingReactor::remove_source(bp<ReactorSource> src)
|
||||||
{
|
{
|
||||||
auto ix = std::find(this->source_v_.begin(),
|
auto ix = std::find(this->source_v_.begin(),
|
||||||
this->source_v_.end(),
|
this->source_v_.end(),
|
||||||
|
|
@ -46,7 +45,7 @@ namespace xo {
|
||||||
} /*remove_source*/
|
} /*remove_source*/
|
||||||
|
|
||||||
void
|
void
|
||||||
PollingReactor::notify_source_primed(brw<ReactorSource>) {
|
PollingReactor::notify_source_primed(bp<ReactorSource>) {
|
||||||
/* nothing to do here -- all sources always checked by polling loop */
|
/* nothing to do here -- all sources always checked by polling loop */
|
||||||
} /*notify_source_primed*/
|
} /*notify_source_primed*/
|
||||||
|
|
||||||
|
|
@ -57,7 +56,7 @@ namespace xo {
|
||||||
|
|
||||||
/* search sources [ix .. z) */
|
/* search sources [ix .. z) */
|
||||||
for(size_t ix = start_ix; ix < z; ++ix) {
|
for(size_t ix = start_ix; ix < z; ++ix) {
|
||||||
brw<ReactorSource> src = this->source_v_[ix];
|
bp<ReactorSource> src = this->source_v_[ix];
|
||||||
|
|
||||||
if(src->is_nonempty())
|
if(src->is_nonempty())
|
||||||
return ix;
|
return ix;
|
||||||
|
|
@ -65,7 +64,7 @@ namespace xo {
|
||||||
|
|
||||||
/* search source [0 .. ix) */
|
/* search source [0 .. ix) */
|
||||||
for(size_t ix = 0, n = std::min(start_ix, z); ix < n; ++ix) {
|
for(size_t ix = 0, n = std::min(start_ix, z); ix < n; ++ix) {
|
||||||
brw<ReactorSource> src = this->source_v_[ix];
|
bp<ReactorSource> src = this->source_v_[ix];
|
||||||
|
|
||||||
if(src->is_nonempty())
|
if(src->is_nonempty())
|
||||||
return ix;
|
return ix;
|
||||||
|
|
@ -86,7 +85,7 @@ namespace xo {
|
||||||
uint64_t retval = 0;
|
uint64_t retval = 0;
|
||||||
|
|
||||||
if(ix >= 0) {
|
if(ix >= 0) {
|
||||||
brw<ReactorSource> src = this->source_v_[ix];
|
bp<ReactorSource> src = this->source_v_[ix];
|
||||||
|
|
||||||
log && log(xtag("src.name", src->name()));
|
log && log(xtag("src.name", src->name()));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue