Skip to content

Commit

Permalink
Removed some unneeded includes.
Browse files Browse the repository at this point in the history
Bonus: Added example project for ISRTaskEventQueue.
Closes #5
  • Loading branch information
PerMalmberg committed Nov 15, 2018
1 parent da2ac2d commit 64cbf76
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 218 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ else ()
add_subdirectory(test/spiflash)
add_subdirectory(test/sdcard_test)
add_subdirectory(test/sntp)
#add_subdirectory(test/interrupt_queue) // Only compiles for ESP
add_subdirectory(test/main)
endif ()
7 changes: 2 additions & 5 deletions lib/smooth/core/ipc/QueueNotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
//

#include <thread>
#include <smooth/core/Task.h>
#include <smooth/core/ipc/QueueNotification.h>
#include <smooth/core/timer/ElapsedTime.h>
#include <smooth/core/logging/log.h>


namespace smooth
Expand All @@ -21,7 +18,7 @@ namespace smooth
// as TaskEventQueues only call this method when they have successfully added the
// data item to their internal queue. As such, the queue can only be as large as
// the sum of all queues within the same Task.
std::unique_lock<std::mutex> lock(guard);
std::unique_lock<std::mutex> lock{guard};
queues.push(queue);
cond.notify_one();
}
Expand All @@ -30,7 +27,7 @@ namespace smooth
{
ITaskEventQueue* res = nullptr;

std::unique_lock<std::mutex> lock(guard);
std::unique_lock<std::mutex> lock{guard};

if (queues.empty())
{
Expand Down
1 change: 1 addition & 0 deletions lib/smooth/core/network/SocketDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Created by permal on 7/1/17.
//

#include <algorithm>
#include <functional>
#include <smooth/core/network/SocketDispatcher.h>
#include <smooth/core/task_priorities.h>
Expand Down
10 changes: 3 additions & 7 deletions lib/smooth/include/smooth/core/ipc/QueueNotification.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@

#pragma once

#include <chrono>
#include <queue>
#include <condition_variable>
#include <mutex>
#include <algorithm>
#include <queue>
#include "ITaskEventQueue.h"
#include <smooth/core/timer/ElapsedTime.h>

namespace smooth
{
namespace core
{
class Task;

namespace ipc
{
class QueueNotification
Expand All @@ -31,7 +27,7 @@ namespace smooth
void clear()
{
std::lock_guard<std::mutex> lock(guard);
while(queues.size())
while(!queues.empty())
{
queues.pop();
}
Expand Down
1 change: 0 additions & 1 deletion lib/smooth/include/smooth/core/ipc/TaskEventQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <smooth/core/Task.h>
#include "ITaskEventQueue.h"
#include "IEventListener.h"
#include "Link.h"
#include "QueueNotification.h"

namespace smooth
Expand Down
5 changes: 3 additions & 2 deletions lib/smooth/include/smooth/core/timer/TimerService.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

#pragma once

#include <algorithm>
#include <condition_variable>
#include <functional>
#include <memory>
#include <queue>
#include <mutex>
#include <condition_variable>
#include <queue>
#include <smooth/core/Task.h>

namespace smooth
Expand Down
174 changes: 0 additions & 174 deletions old_CMakeLists.txt

This file was deleted.

28 changes: 0 additions & 28 deletions old_component.mk

This file was deleted.

1 change: 1 addition & 0 deletions test/interrupt_queue/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/../common_project.cmake)
29 changes: 29 additions & 0 deletions test/interrupt_queue/interrupt_queue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Created by permal on 2018-10-21.
//

#include "interrupt_queue.h"
#include <smooth/core/Task.h>
#include <smooth/core/task_priorities.h>

using namespace smooth::core;

namespace interrupt_queue
{
App::App()
: Application(smooth::core::APPLICATION_BASE_PRIO, std::chrono::seconds(1)),
queue(*this, *this),
input(queue, GPIO_NUM_21, true, false, GPIO_INTR_ANYEDGE)
{
}

void App::init()
{
std::cout << "Trigger the input!" << std::endl;
}

void App::event(const smooth::core::io::InterruptInputEvent& value)
{
std::cout << "Value from interrupt: " << value.get_state() << std::endl;
}
}
27 changes: 27 additions & 0 deletions test/interrupt_queue/interrupt_queue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include <iostream>
#include <smooth/core/Application.h>
#include <smooth/core/task_priorities.h>
#include <smooth/core/io/InterruptInput.h>
#include <smooth/core/ipc/ISRTaskEventQueue.h>
#include <smooth/core/ipc/IEventListener.h>

namespace interrupt_queue
{
class App
: public smooth::core::Application,
public smooth::core::ipc::IEventListener<smooth::core::io::InterruptInputEvent>
{
public:
App();

void init() override;

void event(const smooth::core::io::InterruptInputEvent& value) override;

protected:
smooth::core::ipc::ISRTaskEventQueue<smooth::core::io::InterruptInputEvent, 5> queue;
smooth::core::io::InterruptInput input;
};
}
2 changes: 2 additions & 0 deletions test/json_test/json_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "json_test.h"

#include <algorithm>
#include <fstream>
#include <cassert>
#include <json/cJSON/cJSON.h>
Expand Down

0 comments on commit 64cbf76

Please sign in to comment.