Program Listing for File ucb1_allocator.hpp

Return to documentation for file (cosm/ta/ucb1_allocator.hpp)

#pragma once

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include <vector>

#include "rcppsw/common/common.hpp"
#include "rcppsw/er/client.hpp"
#include "rcppsw/math/rng.hpp"
#include "rcppsw/rcppsw.hpp"

/*******************************************************************************
 * Namespaces/Decls
 ******************************************************************************/
namespace cosm::ta {
class polled_task;

/*******************************************************************************
 * Class Definitions
 ******************************************************************************/
class ucb1_allocator : public rer::client<ucb1_allocator> {
 public:
  explicit ucb1_allocator(rmath::rng* rng)
      : ER_CLIENT_INIT("cosm.ta.ucb1_allocator"), m_rng(rng) {}

  /* Not copy constructable/assignable by default */
  ucb1_allocator(const ucb1_allocator&) = delete;
  const ucb1_allocator& operator=(const ucb1_allocator&) = delete;

  polled_task* operator()(const std::vector<polled_task*>& tasks,
                          size_t alloc_count) const;

 private:
  /* clang-format off */
  rmath::rng* m_rng;
  /* clang-format on */
};

} /* namespace cosm::ta */