|
Load Balancer Simulator
CSCE 412 - Load Balancer Simulation Project
|
Simulates a web server that receives and processes requests from the load balancer. More...
#include <WebServer.h>
Public Member Functions | |
| WebServer (int id) | |
| Constructs a WebServer with the given ID. More... | |
| ~WebServer () | |
| Destructor. Cleans up any assigned request to prevent memory leaks. More... | |
| int | getId () |
| Returns the server's unique ID. More... | |
| const bool | tick () |
| Advances the server by one clock cycle. More... | |
| void | assignRequest (Request *req) |
| Assigns a new request to this server for processing. More... | |
Private Attributes | |
| int | id |
| Unique identifier for this server. More... | |
| Request * | currRequest |
| Pointer to the currently assigned request, or nullptr if idle. More... | |
| int | cyclesRemaining |
| Clock cycles remaining to finish the current request. More... | |
Simulates a web server that receives and processes requests from the load balancer.
Each WebServer processes one request at a time. It counts down clock cycles until the request is complete, then becomes available for a new request.
Definition at line 17 of file WebServer.h.
| WebServer::WebServer | ( | int | id | ) |
Constructs a WebServer with the given ID.
| id | Unique server identifier |
Definition at line 8 of file WebServer.cpp.
| WebServer::~WebServer | ( | ) |
Destructor. Cleans up any assigned request to prevent memory leaks.
Definition at line 14 of file WebServer.cpp.
| void WebServer::assignRequest | ( | Request * | req | ) |
Assigns a new request to this server for processing.
| req | Pointer to the Request to process (takes ownership) |
Definition at line 42 of file WebServer.cpp.
| int WebServer::getId | ( | ) |
| const bool WebServer::tick | ( | ) |
Advances the server by one clock cycle.
Definition at line 26 of file WebServer.cpp.
|
private |
Pointer to the currently assigned request, or nullptr if idle.
Definition at line 20 of file WebServer.h.
|
private |
Clock cycles remaining to finish the current request.
Definition at line 21 of file WebServer.h.
|
private |
Unique identifier for this server.
Definition at line 19 of file WebServer.h.