GithubHelp home page GithubHelp logo

router_on_roles's Introduction

Build

mvn compile exec:java

Goal

I have a simple java object (router) that is the player. Depending on the context, it may play different routing algorithms.

When two devices meet, for every stored message, a router activates a compartment that adapts the routing algorithm. Next, it plays the role "route" and decides wether the message should be forwarded. Then it gets the next stored message and starts over.

Diagram

Diagram

Problem

When I activate a compartment, I pass the object router. The adapt function is scala calls

Router play new AlgorithmA

At this point I have the following:

Router (plays) AlgorithmA

Next, if I adapt to algorithmB, I expected to have

Router (plays) AlgorithmB

But it seems that I get:

Router (plays) AlgorithmA (plays) AlgorithmB

Is it possible (other than using a singleton) to exchange a role instead of having a "role-plays-role" behavior?

Without cycles I am getting:

[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ scroll-router ---
1.57141338E9 seconds to process the last 1000 role changes
0.289 seconds to process the last 1000 role changes
0.227 seconds to process the last 1000 role changes
0.242 seconds to process the last 1000 role changes
0.295 seconds to process the last 1000 role changes
0.368 seconds to process the last 1000 role changes
0.429 seconds to process the last 1000 role changes
0.53 seconds to process the last 1000 role changes
0.592 seconds to process the last 1000 role changes
0.716 seconds to process the last 1000 role changes
0.813 seconds to process the last 1000 role changes
0.857 seconds to process the last 1000 role changes
0.959 seconds to process the last 1000 role changes
1.139 seconds to process the last 1000 role changes
1.244 seconds to process the last 1000 role changes

Allowing Cycles:

[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ scroll-router ---
1.57141363E9 seconds to process the last 1000 role changes
0.415 seconds to process the last 1000 role changes
0.276 seconds to process the last 1000 role changes
0.318 seconds to process the last 1000 role changes
0.437 seconds to process the last 1000 role changes
0.541 seconds to process the last 1000 role changes
0.669 seconds to process the last 1000 role changes
0.834 seconds to process the last 1000 role changes
0.94 seconds to process the last 1000 role changes
1.059 seconds to process the last 1000 role changes
1.28 seconds to process the last 1000 role changes
1.389 seconds to process the last 1000 role changes
1.543 seconds to process the last 1000 role changes
1.747 seconds to process the last 1000 role changes
1.91 seconds to process the last 1000 role changes

router_on_roles's People

Contributors

irigon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.