#ifndef PLS_SCHEDULER_MEMORY_H
#define PLS_SCHEDULER_MEMORY_H

#include "pls/internal/base/thread.h"
#include "pls/internal/scheduling/thread_state.h"

namespace pls {
namespace internal {
namespace scheduling {

// TODO: This way to handle memory is kind of a mess. We reworked it once...maybe it needs a second visit
//       especially with the new 'stagered stack' (mmap allocs with page faults would be nice).
class scheduler_memory {
  // Note: scheduler_memory is a pure interface and has no data.
  //       By not having an initialization routine we can do our 'static and heap specialization'
  //       without running into any ordering problems in the initialization sequence.

 protected:
  thread_state **thread_states_array_{nullptr};

 public:
  virtual size_t max_threads() const = 0;
  virtual base::thread &thread_for(size_t id) = 0;
  thread_state &thread_state_for(size_t id) {
    return *thread_states_array_[id];
  }
};

}
}
}

#endif //PLS_SCHEDULER_MEMORY_H
