Skip to content

New release #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions include/scl/simulation/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ enum class EventType {
SEND,

/**
* @brief Event generated when data is received on a channel.
* @brief Event generated when data is read from a channel.
*/
RECV,
READ,

/**
* @brief Event generated when a channel is queried for the presence of data.
Expand Down Expand Up @@ -146,12 +146,12 @@ struct Event {
std::size_t amount);

/**
* @brief Create an event indicating that some data was received on a channel.
* @param timestamp the time the data was received.
* @brief Create an event indicating that some data was read from a channel.
* @param timestamp the time the data was read.
* @param channel_id the ID of the channel.
* @param amount the amount of bytes received.
* @param amount the amount of bytes read.
*/
static std::shared_ptr<Event> recvData(util::Time::Duration timestamp,
static std::shared_ptr<Event> readData(util::Time::Duration timestamp,
ChannelId channel_id,
std::size_t amount);

Expand Down
2 changes: 1 addition & 1 deletion src/scl/simulation/channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ coro::Task<net::Packet> sim::details::SimulatedChannel::recv() {
elapsed = m_context.recv(m_cid.remote, totalPacketSize(packet), elapsed);

const std::size_t nbytes = totalPacketSize(packet);
m_context.recordEvent(Event::recvData(elapsed, m_cid, nbytes));
m_context.recordEvent(Event::readData(elapsed, m_cid, nbytes));
m_context.startClock();
co_return packet;
}
Expand Down
10 changes: 5 additions & 5 deletions src/scl/simulation/event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ std::shared_ptr<sim::Event> sim::Event::sendData(util::Time::Duration timestamp,
amount);
}

std::shared_ptr<sim::Event> sim::Event::recvData(util::Time::Duration timestamp,
std::shared_ptr<sim::Event> sim::Event::readData(util::Time::Duration timestamp,
sim::ChannelId channel_id,
std::size_t amount) {
return std::make_shared<ChannelDataEvent>(EventType::RECV,
return std::make_shared<ChannelDataEvent>(EventType::READ,
timestamp,
channel_id,
amount);
Expand Down Expand Up @@ -118,8 +118,8 @@ std::string eventTypeToString(sim::EventType type) {
case sim::EventType::SEND:
return "SEND";
break;
case sim::EventType::RECV:
return "RECV";
case sim::EventType::READ:
return "READ";
break;
case sim::EventType::HAS_DATA:
return "HAS_DATA";
Expand Down Expand Up @@ -263,7 +263,7 @@ std::ostream& sim::operator<<(std::ostream& stream, const sim::Event* event) {
break;

case EventType::SEND:
case EventType::RECV:
case EventType::READ:
writeEvent(stream, dynamic_cast<const ChannelDataEvent*>(event));
break;

Expand Down
2 changes: 1 addition & 1 deletion test/scl/simulation/test_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ TEST_CASE("SimulatedChannel send/recv", "[sim]") {
REQUIRE(pr.read<int>() == 3);

REQUIRE(gctx.traces[1].size() == 2);
REQUIRE(gctx.traces[1].back()->type == sim::EventType::RECV);
REQUIRE(gctx.traces[1].back()->type == sim::EventType::READ);
REQUIRE(getChannelDataEventAmount(gctx.traces[1].back()) == expected_size);

REQUIRE(gctx.sends[{0, 1}].empty());
Expand Down
4 changes: 2 additions & 2 deletions test/scl/simulation/test_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ TEST_CASE("Simulation events", "[sim]") {
}

SECTION("RECV") {
auto e = sim::Event::recvData(123ms, {1, 2}, 10);
auto e = sim::Event::readData(123ms, {1, 2}, 10);
REQUIRE(str(e) ==
"{"
"\"timestamp\":123,"
"\"type\":\"RECV\","
"\"type\":\"READ\","
"\"metadata\":{"
"\"channel_id\":{\"local\":1,\"remote\":2},"
"\"amount\":10"
Expand Down
2 changes: 1 addition & 1 deletion test/scl/simulation/test_simulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ TEST_CASE("Simulate SendRecv protocol", "[sim]") {
REQUIRE(trace[0]->type == sim::EventType::START);
REQUIRE(trace[1]->type == sim::EventType::PROTOCOL_BEGIN);
REQUIRE(trace[2]->type == sim::EventType::SEND);
REQUIRE(trace[3]->type == sim::EventType::RECV);
REQUIRE(trace[3]->type == sim::EventType::READ);
REQUIRE(trace[4]->type == sim::EventType::CLOSE);
REQUIRE(trace[5]->type == sim::EventType::CLOSE);
REQUIRE(trace[6]->type == sim::EventType::PROTOCOL_END);
Expand Down
Loading