COS 520 Lamport 2 / Process.hpp

Full commit
#ifndef PROCESS_HPP_
#define PROCESS_HPP_

#include <stdlib.h>
#include <queue>
#include <iostream>
#include <set>

class Simulation;
#include "Request.hpp"
#include "Message.hpp"

class Process

  Process(int id, Simulation* simulation, int total, float p, int delta);
  type::process_id getID() const;
  Request generateRequest();  // Stochastically generates a Request
  void destabilize();  // Stochastically goes down at times
  void display();  // print basic info about the object's state
  void pushRequest(Request request);  // "sends" Request to Process, simulates time lag
  void pushMessage(Message m);
  void tick();
  bool isUp();

  Simulation* simulation;
  int id;
  int total;  // total number of processes
  float prob;  // probability of generating a request
  type::time delta;
  bool up;
  std::set<Request> requests;  // set of generated Requests
  std::set<Message> messages;  // set of pointers to incoming Messages
  void vote(Request r);
  void vote(Message m);
  void readRequests();  // Deal with incoming Requests
  void readMessages();  // Deal with incoming Messages
  void removeRequest(Request r);
  void removeMessage(Message m);
  void goDown();