
#ifndef PLS_DATAFLOW_INTERNAL_TOKEN_H_
#define PLS_DATAFLOW_INTERNAL_TOKEN_H_

namespace pls {
namespace dataflow {
namespace internal {

/**
 * Parallel invocations of the same sub-graph are usually working with some kind of coloring
 * for tokens to distinguishe different invocations. As this concept is abstract and we could
 * change it in the future (for e.g. more advanced features/dataflows) we encapsulate it.
 */
struct token_color {
  unsigned int clock_;

  int get_index(int parallel_limit) const {
    return clock_ % parallel_limit;
  }
};

template<typename T>
class token {
  T value_;
  token_color color_;

 public:
  T value() const { return value_; }
  token_color color() const { return color_; }
};

}
}
}

#endif //PLS_DATAFLOW_INTERNAL_TOKEN_H_
