Skip to content

Commit

Permalink
Generic JArrow::get_pending()
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwbrei committed Dec 27, 2023
1 parent 0205b1d commit 4447bf6
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/libraries/JANA/Engine/JArrow.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class JArrow {
virtual void finalize() {};

// TODO: Make no longer virtual
virtual size_t get_pending() { return 0; }
virtual size_t get_pending();

// TODO: Get rid of me
virtual size_t get_threshold() { return 0; }
Expand Down Expand Up @@ -126,6 +126,8 @@ struct PlaceRefBase {
bool is_input = false;
size_t min_item_count = 1;
size_t max_item_count = 1;

virtual size_t get_pending() { return 0; }
};

template <typename T>
Expand Down Expand Up @@ -156,6 +158,15 @@ struct PlaceRef : public PlaceRefBase {
this->max_item_count = max_item_count;
}

// TODO: We can get de-virtualize this if we go the parameter pack route
size_t get_pending() override {
if (is_input && is_queue) {
auto queue = static_cast<JMailbox<T*>*>(place_ref);
return queue->size();
}
return 0;
}

bool pull(Data<T>& data) {
if (is_input) { // Actually pull the data
if (is_queue) {
Expand Down Expand Up @@ -219,6 +230,13 @@ struct PlaceRef : public PlaceRefBase {
}
};

inline size_t JArrow::get_pending() {
size_t sum = 0;
for (PlaceRefBase* place : m_places) {
sum += place->get_pending();
}
return sum;
}


#endif // GREENFIELD_ARROW_H

0 comments on commit 4447bf6

Please sign in to comment.