Skip to content

Commit

Permalink
Limit producer to single thread (#37)
Browse files Browse the repository at this point in the history
* Producer のスレッドを単一に変更
  • Loading branch information
idofront authored Dec 7, 2024
1 parent d8449d9 commit 602e07e
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 55 deletions.
26 changes: 0 additions & 26 deletions include/TrafficPlayer.hpp

This file was deleted.

11 changes: 1 addition & 10 deletions main/TrafficPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@
#include <TrafficMaker/PacketsPerSecondTrafficMaker.hpp>
#include <TrafficMaker/SpeedScaledReplayTrafficMaker.hpp>
#include <TrafficMaker/UniformThroughputTrafficMaker.hpp>
#include <TrafficPlayer.hpp>
#include <TrafficRecord.hpp>
#include <boost/format.hpp>
#include <filesystem>
#include <iostream>
#include <pcap.h>
#include <spdlog/spdlog.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
Expand Down Expand Up @@ -66,7 +57,7 @@ int main(int argc, char *argv[])

const auto NUM_OF_DEALERS = 1;
const auto NUM_OF_REPORTERS = 1;
const auto NUM_OF_PRODUCERS = std::thread::hardware_concurrency();
const auto NUM_OF_PRODUCERS = 1;
const auto NUM_OF_THREADS = NUM_OF_DEALERS + NUM_OF_REPORTERS + NUM_OF_PRODUCERS;
auto employer = Thread::Employer(NUM_OF_THREADS);

Expand Down
3 changes: 3 additions & 0 deletions src/Dealer/DealReporter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <Dealer/DealReporter.hpp>
#include <UnitConverter/SiPrefixConversion.hpp>
#include <boost/format.hpp>
#include <numeric>
#include <spdlog/spdlog.h>

DealReporter::DealReporter(Dealer &dealer, std::chrono::milliseconds interval)
: _Dealer(dealer), _Interval(interval), _UnitConverter(std::make_unique<SiPrefixConversion>()),
Expand Down
6 changes: 0 additions & 6 deletions src/Dealer/DealReporter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
#define DEALER__DEAL_REPORTER_HPP

#include <Dealer/Dealer.hpp>
#include <Queue/ThreadSafeQueue.hpp>
#include <Thread/Runnable.hpp>
#include <UnitConverter/BinaryPrefixConversion.hpp>
#include <UnitConverter/NoConversion.hpp>
#include <UnitConverter/SiPrefixConversion.hpp>
#include <UnitConverter/UnitConverter.hpp>
#include <chrono>
#include <memory>

class DealReporter : public Thread::Runnable
{
Expand Down
8 changes: 6 additions & 2 deletions src/Dealer/Dealer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#include <Dealer/Dealer.hpp>
#include <arpa/inet.h>
#include <boost/format.hpp>
#include <netinet/ether.h>
#include <numeric>
#include <spdlog/spdlog.h>
#include <string.h>
#include <sys/ioctl.h>

Dealer::Dealer(std::shared_ptr<ThreadSafeQueue<TrafficRecord>> queue, const std::string &device_name)
: queue(queue), device_name(device_name), ReportsPtr(std::make_shared<ThreadSafeQueue<DealReport>>())
Expand All @@ -22,8 +28,6 @@ void Dealer::Task()

if (result.has_value())
{
auto str = TrafficPlayer::HexString(result.value().Data());
spdlog::trace("Deal: {}", str);
try
{
Send(result.value().Data());
Expand Down
9 changes: 0 additions & 9 deletions src/Dealer/Dealer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,9 @@
#include <Dealer/DealReport.hpp>
#include <Queue/ThreadSafeQueue.hpp>
#include <Thread/Runnable.hpp>
#include <TrafficPlayer.hpp>
#include <TrafficRecord.hpp>
#include <arpa/inet.h>
#include <boost/format.hpp>
#include <linux/if_packet.h>
#include <memory>
#include <net/if.h>
#include <netinet/ether.h>
#include <spdlog/spdlog.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>

class Dealer : public Thread::Runnable
{
Expand Down
1 change: 0 additions & 1 deletion src/Producer/Producer.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef PRODUCER__PRODUCER_HPP
#define PRODUCER__PRODUCER_HPP

#include <Queue/IThreadSafeQueue.hpp>
#include <Thread/Runnable.hpp>
#include <TimingAdjuster/ReserveTimeRecord.hpp>
#include <TrafficRecord.hpp>
Expand Down
1 change: 0 additions & 1 deletion src/TimingAdjuster/ReserveTimingAdjuster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <Queue/BoundedThreadSafeQueue.hpp>
#include <Queue/ThreadSafeQueue.hpp>
#include <TimingAdjuster/ReserveTimeRecord.hpp>
#include <TrafficPlayer.hpp>
#include <TrafficRecord.hpp>
#include <memory>
#include <spdlog/spdlog.h>
Expand Down

0 comments on commit 602e07e

Please sign in to comment.