public:
- ClientInfo info;
+ const ClientInfo* info;
bool idle;
Counter last_tick;
uint32_t cur_rho;
uint32_t cur_delta;
ClientRec(C _client,
- const ClientInfo& _info,
+ const ClientInfo* _info,
Counter current_tick) :
client(_client),
prev_tag(0.0, 0.0, 0.0, TimeZero),
// a function that can be called to look up client information
- using ClientInfoFunc = std::function<ClientInfo(const C&)>;
+ using ClientInfoFunc = std::function<const ClientInfo*(const C&)>;
bool empty() const {
}
- inline const ClientInfo get_cli_info(ClientRec& client) const {
+ inline const ClientInfo* get_cli_info(ClientRec& client) const {
if (is_dynamic_cli_info_f) {
client.info = client_info_f(client.client);
}
if (client_map.end() != client_it) {
temp_client = &(*client_it->second); // address of obj of shared_ptr
} else {
- ClientInfo info = client_info_f(client_id);
+ const ClientInfo* info = client_info_f(client_id);
ClientRecRef client_rec =
std::make_shared<ClientRec>(client_id, info, tick);
resv_heap.push(client_rec);
RequestTag tag(0, 0, 0, time);
if (!client.has_request()) {
+ const ClientInfo* client_info = get_cli_info(client);
+ assert(client_info);
tag = RequestTag(client.get_req_tag(),
- get_cli_info(client),
+ *client_info,
req_params,
time,
cost,
client.update_req_tag(tag, tick);
}
#else
+ const ClientInfo* client_info = get_cli_info(client);
+ assert(client_info);
RequestTag tag(client.get_req_tag(),
- get_cli_info(client),
+ *client_info,
req_params,
time,
cost,
#ifndef DO_NOT_DELAY_TAG_CALC
if (top.has_request()) {
ClientReq& next_first = top.next_request();
- next_first.tag = RequestTag(tag, get_cli_info(top),
+ const ClientInfo* client_info = get_cli_info(top);
+ assert(client_info);
+ next_first.tag = RequestTag(tag, *client_info,
top.cur_delta, top.cur_rho,
next_first.tag.arrival,
0.0, anticipation_timeout);
// data_mtx should be held when called
void reduce_reservation_tags(ClientRec& client) {
for (auto& r : client.requests) {
- r.tag.reservation -= client.info.reservation_inv;
+ r.tag.reservation -= client.info->reservation_inv;
#ifndef DO_NOT_DELAY_TAG_CALC
// reduce only for front tag. because next tags' value are invalid
#endif
}
// don't forget to update previous tag
- client.prev_tag.reservation -= client.info.reservation_inv;
+ client.prev_tag.reservation -= client.info->reservation_inv;
resv_heap.promote(client);
}
dmc::ClientInfo ci1(reservation, weight, 0.0);
dmc::ClientInfo ci2(reservation, weight, 1.0);
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- if (client1 == c) return ci1;
- else if (client2 == c) return ci2;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ if (client1 == c) return &ci1;
+ else if (client2 == c) return &ci2;
else {
ADD_FAILURE() << "got request from neither of two clients";
- return ci1; // must return
+ return nullptr;
}
};
double reservation = 100.0;
dmc::ClientInfo ci(reservation, 1.0, 0.0);
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo { return ci; };
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ return &ci;
+ };
auto server_ready_f = [] () -> bool { return true; };
auto submit_req_f = [] (const ClientId& c,
std::unique_ptr<Request> req,
dmc::ClientInfo ci(1.0, 0.0, 0.0);
Queue pq;
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo { return ci; };
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ return &ci;
+ };
auto server_ready_f = [] () -> bool { return true; };
auto submit_req_f = [&] (const ClientId& c,
std::unique_ptr<Request> req,
dmc::ClientInfo info1(0.0, 1.0, 0.0);
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- return info1;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ return &info1;
};
Queue pq(client_info_f, true);
dmc::ClientInfo info1(0.0, 1.0, 0.0);
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- return info1;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ return &info1;
};
Queue pq(client_info_f, true);
dmc::ClientInfo info1(0.0, 1.0, 0.0);
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- return info1;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ return &info1;
};
Queue pq(client_info_f, true);
dmc::ClientInfo info1(0.0, 1.0, 0.0);
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- return info1;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ return &info1;
};
Queue pq(client_info_f, true);
QueueRef pq;
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- if (client1 == c) return info1;
- else if (client2 == c) return info2;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ if (client1 == c) return &info1;
+ else if (client2 == c) return &info2;
else {
ADD_FAILURE() << "client info looked up for non-existant client";
- return info1;
+ return nullptr;
}
};
dmc::ClientInfo info1(2.0, 0.0, 0.0);
dmc::ClientInfo info2(1.0, 0.0, 0.0);
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- if (client1 == c) return info1;
- else if (client2 == c) return info2;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ if (client1 == c) return &info1;
+ else if (client2 == c) return &info2;
else {
ADD_FAILURE() << "client info looked up for non-existant client";
- return info1;
+ return nullptr;
}
};
QueueRef pq;
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- if (client1 == c) return info1;
- else if (client2 == c) return info2;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ if (client1 == c) return &info1;
+ else if (client2 == c) return &info2;
else {
ADD_FAILURE() << "client info looked up for non-existant client";
- return info1;
+ return nullptr;
}
};
QueueRef pq;
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- if (client1 == c) return info1[cli_info_group];
- else if (client2 == c) return info2[cli_info_group];
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ if (client1 == c) return &info1[cli_info_group];
+ else if (client2 == c) return &info2[cli_info_group];
else {
ADD_FAILURE() << "client info looked up for non-existant client";
- return info1[0];
+ return nullptr;
}
};
dmc::ClientInfo info1(1.0, 0.0, 0.0);
dmc::ClientInfo info2(1.0, 0.0, 0.0);
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- if (client1 == c) return info1;
- else if (client2 == c) return info2;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ if (client1 == c) return &info1;
+ else if (client2 == c) return &info2;
else {
ADD_FAILURE() << "client info looked up for non-existant client";
- return info1;
+ return nullptr;
}
};
dmc::ClientInfo info(1.0, 1.0, 1.0);
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- return info;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ return &info;
};
QueueRef pq(new Queue(client_info_f, false));
dmc::ClientInfo info(1.0, 0.0, 1.0);
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- return info;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ return &info;
};
QueueRef pq(new Queue(client_info_f, false));
dmc::ClientInfo info(0.0, 1.0, 1.0);
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- return info;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ return &info;
};
QueueRef pq(new Queue(client_info_f, true));
dmc::ClientInfo info(1.0, 0.0, 1.0);
- auto client_info_f = [&] (ClientId c) -> dmc::ClientInfo {
- return info;
+ auto client_info_f = [&] (ClientId c) -> const dmc::ClientInfo* {
+ return &info;
};
QueueRef pq(new Queue(client_info_f, true));