#pragma once

#include <mutex>
#include <vector>

namespace th_safe {
class forks {
public:
  explicit forks(std::size_t count) : mutexes_(count) {}

  std::mutex &left(std::size_t i) { return mutexes_[i]; }

  std::mutex &right(std::size_t i) {
    return mutexes_[(i + 1) % mutexes_.size()];
  }

  std::size_t size() const { return mutexes_.size(); }

private:
  std::vector<std::mutex> mutexes_;
};
} // namespace th_safe
