Aggie Student Toolkit — Load Balancer
CSCE 412 Project 4
Arnav Fotedar · Fall 2026 · C++ load balancer simulation
Toggle main menu visibility
Loading...
Searching...
No Matches
WebServer.h
Go to the documentation of this file.
1
6
7
#ifndef WEBSERVER_H
8
#define WEBSERVER_H
9
10
#include <optional>
11
12
#include "
Request.h
"
13
26
class
WebServer
{
27
public
:
33
explicit
WebServer
(
unsigned
int
id
,
unsigned
long
createdCycle
= 0);
34
36
unsigned
int
id
()
const
;
37
39
bool
isIdle
()
const
;
40
42
bool
isRetiring
()
const
;
43
48
void
setRetiring
(
bool
retiring);
49
60
void
assign
(
const
Request
& request,
unsigned
long
cycle);
61
66
bool
tick
();
67
69
const
std::optional<Request>&
current
()
const
;
70
72
const
Request
&
lastCompleted
()
const
;
73
75
unsigned
int
remainingCycles
()
const
;
76
78
unsigned
long
completedCount
()
const
;
79
81
unsigned
long
busyCycles
()
const
;
82
84
unsigned
long
createdCycle
()
const
;
85
86
private
:
87
unsigned
int
id_;
88
unsigned
long
createdCycle_;
89
std::optional<Request> current_;
90
Request
lastCompleted_;
91
unsigned
int
remainingCycles_ = 0;
92
unsigned
long
completedCount_ = 0;
93
unsigned
long
busyCycles_ = 0;
94
bool
retiring_ =
false
;
95
};
96
97
#endif
Request.h
Defines the Request structure and its JobType that flow through the load balancer.
WebServer::assign
void assign(const Request &request, unsigned long cycle)
Starts processing a request.
Definition
WebServer.cpp:30
WebServer::remainingCycles
unsigned int remainingCycles() const
Definition
WebServer.cpp:67
WebServer::isIdle
bool isIdle() const
Definition
WebServer.cpp:18
WebServer::WebServer
WebServer(unsigned int id, unsigned long createdCycle=0)
Creates an idle server.
Definition
WebServer.cpp:11
WebServer::busyCycles
unsigned long busyCycles() const
Definition
WebServer.cpp:75
WebServer::lastCompleted
const Request & lastCompleted() const
Definition
WebServer.cpp:63
WebServer::setRetiring
void setRetiring(bool retiring)
Marks or unmarks the server for retirement.
Definition
WebServer.cpp:26
WebServer::isRetiring
bool isRetiring() const
Definition
WebServer.cpp:22
WebServer::current
const std::optional< Request > & current() const
Definition
WebServer.cpp:59
WebServer::completedCount
unsigned long completedCount() const
Definition
WebServer.cpp:71
WebServer::createdCycle
unsigned long createdCycle() const
Definition
WebServer.cpp:79
WebServer::tick
bool tick()
Advances the server by one clock cycle.
Definition
WebServer.cpp:44
WebServer::id
unsigned int id() const
Definition
WebServer.cpp:14
Request
A single web request waiting for, or receiving, service.
Definition
Request.h:41
WebServer.h
Generated by
1.18.0