[DEV] remove STL

This commit is contained in:
Edouard DUPIN 2017-09-07 23:38:26 +02:00
parent 29607a6d46
commit 73c73ef1f5
12 changed files with 26 additions and 26 deletions

View File

@ -139,7 +139,7 @@ void enet::Http::threadCallback() {
void enet::Http::start() {
ENET_DEBUG("connect [START]");
m_threadRunning = true;
m_thread = new std::thread([&](void *){ this->threadCallback();}, nullptr);
m_thread = new ethread::Thread([&](void *){ this->threadCallback();}, nullptr);
if (m_thread == nullptr) {
m_threadRunning = false;
ENET_ERROR("creating callback thread!");

View File

@ -8,7 +8,7 @@
#include <enet/Tcp.hpp>
#include <etk/Vector.hpp>
#include <etk/Map.hpp>
#include <thread>
#include <ethread/Thread.hpp>
#include <ethread/tools.hpp>
#include <functional>
@ -216,7 +216,7 @@ namespace enet {
protected:
enet::Tcp m_connection;
bool m_headerIsSend;
std::thread* m_thread;
ethread::Thread* m_thread;
bool m_threadRunning;
etk::Vector<uint8_t> m_temporaryBuffer;
private:
@ -230,7 +230,7 @@ namespace enet {
return m_connection.getConnectionStatus() == enet::Tcp::status::link;
}
public:
using Observer = std::function<void(etk::Vector<uint8_t>&)>; //!< Define an Observer: function pointer
using Observer = etk::Function<void(etk::Vector<uint8_t>&)>; //!< Define an Observer: function pointer
Observer m_observer;
/**
* @brief Connect an function member on the signal with the shared_ptr object.
@ -248,7 +248,7 @@ namespace enet {
m_observer = _func;
}
public:
using ObserverRaw = std::function<void(enet::Tcp&)>; //!< Define an Observer: function pointer
using ObserverRaw = etk::Function<void(enet::Tcp&)>; //!< Define an Observer: function pointer
ObserverRaw m_observerRaw;
/**
* @brief Connect an function member on the signal with the shared_ptr object.
@ -266,11 +266,11 @@ namespace enet {
m_observerRaw = _func;
}
public:
using ObserverRequest = std::function<void(const enet::HttpRequest&)>; //!< Define an Observer: function pointer
using ObserverRequest = etk::Function<void(const enet::HttpRequest&)>; //!< Define an Observer: function pointer
protected:
ObserverRequest m_observerRequest;
public:
using ObserverAnswer = std::function<void(const enet::HttpAnswer&)>; //!< Define an Observer: function pointer
using ObserverAnswer = etk::Function<void(const enet::HttpAnswer&)>; //!< Define an Observer: function pointer
protected:
ObserverAnswer m_observerAnswer;
public:

View File

@ -164,7 +164,7 @@ int32_t enet::Tcp::read(void* _data, int32_t _maxLen) {
// Receive data on this connection until the recv fails with EWOULDBLOCK.
// If any other failure occurs, we will close the connection.
{
std::unique_lock<std::mutex> lock(m_mutex);
std::unique_lock<ethread::Mutex> lock(m_mutex);
rc = recv(m_socketId, (char *)_data, _maxLen, 0);
}
if (rc < 0) {
@ -216,7 +216,7 @@ int32_t enet::Tcp::write(const void* _data, int32_t _len) {
//ENET_DEBUG("write on socketid = " << m_socketId << " data@=" << int64_t(_data) << " size=" << _len );
int32_t size;
{
std::unique_lock<std::mutex> lock(m_mutex);
std::unique_lock<ethread::Mutex> lock(m_mutex);
size = ::send(m_socketId, (const char *)_data, _len, 0);
}
if ( size != _len

View File

@ -6,7 +6,7 @@
#pragma once
#include <etk/types.hpp>
#include <mutex>
#include <ethread/Mutex.hpp>
#include <functional>
#ifdef __TARGET_OS__Windows
#include <winsock2.h>
@ -30,7 +30,7 @@ namespace enet {
#ifdef ENET_STORE_INPUT
etk::FSNode m_nodeStoreInput;
#endif
std::mutex m_mutex;
ethread::Mutex m_mutex;
public:
Tcp();
#ifdef __TARGET_OS__Windows

View File

@ -505,7 +505,7 @@ int32_t enet::WebSocket::send() {
}
int32_t enet::WebSocket::write(const void* _data, int32_t _len, bool _isString, bool _mask) {
std::unique_lock<std::mutex> lock(m_mutex);
std::unique_lock<ethread::Mutex> lock(m_mutex);
if (configHeader(_isString, _mask) == false) {
return -1;
}
@ -518,7 +518,7 @@ void enet::WebSocket::controlPing() {
ENET_ERROR("Nullptr interface ...");
return;
}
std::unique_lock<std::mutex> lock(m_mutex);
std::unique_lock<ethread::Mutex> lock(m_mutex);
uint8_t header = enet::websocket::FLAG_FIN
| enet::websocket::OPCODE_FRAME_PING;
m_lastSend = echrono::Steady::now();
@ -532,7 +532,7 @@ void enet::WebSocket::controlPong() {
ENET_ERROR("Nullptr interface ...");
return;
}
std::unique_lock<std::mutex> lock(m_mutex);
std::unique_lock<ethread::Mutex> lock(m_mutex);
uint8_t header = enet::websocket::FLAG_FIN
| enet::websocket::OPCODE_FRAME_PONG;
m_lastSend = echrono::Steady::now();
@ -546,7 +546,7 @@ void enet::WebSocket::controlClose() {
ENET_ERROR("Nullptr interface ...");
return;
}
std::unique_lock<std::mutex> lock(m_mutex);
std::unique_lock<ethread::Mutex> lock(m_mutex);
uint8_t header = enet::websocket::FLAG_FIN
| enet::websocket::OPCODE_FRAME_CLOSE;
m_lastSend = echrono::Steady::now();

View File

@ -21,7 +21,7 @@ namespace enet {
etk::String m_checkKey;
echrono::Steady m_lastReceive;
echrono::Steady m_lastSend;
std::mutex m_mutex;
ethread::Mutex m_mutex;
public:
const echrono::Steady& getLastTimeReceive() {
return m_lastReceive;
@ -52,7 +52,7 @@ namespace enet {
m_protocol = _protocol;
}
public:
using Observer = std::function<void(etk::Vector<uint8_t>&, bool)>; //!< Define an Observer: function pointer
using Observer = etk::Function<void(etk::Vector<uint8_t>&, bool)>; //!< Define an Observer: function pointer
protected:
Observer m_observer;
public:
@ -73,7 +73,7 @@ namespace enet {
}
// Only server:
public:
using ObserverUriCheck = std::function<bool(const etk::String&, const etk::Vector<etk::String>&)>; //!< Define an Observer: function pointer
using ObserverUriCheck = etk::Function<bool(const etk::String&, const etk::Vector<etk::String>&)>; //!< Define an Observer: function pointer
protected:
ObserverUriCheck m_observerUriCheck;
public:
@ -97,8 +97,8 @@ namespace enet {
bool m_haveMask;
uint8_t m_dataMask[4];
public:
std::unique_lock<std::mutex> getScopeLock() {
return etk::move(std::unique_lock<std::mutex>(m_mutex));
std::unique_lock<ethread::Mutex> getScopeLock() {
return etk::move(std::unique_lock<ethread::Mutex>(m_mutex));
}
/**
* Compose the local header inside a temporary buffer ==> must lock external to prevent multiple simultaneous access

View File

@ -28,7 +28,7 @@ def configure(target, my_module):
my_module.add_path(".")
my_module.add_depend([
'enet',
'gtest',
'etest',
'test-debug'
])
my_module.add_src_file([

View File

@ -28,7 +28,7 @@ def configure(target, my_module):
my_module.add_path(".")
my_module.add_depend([
'enet',
'gtest',
'etest',
'test-debug'
])
my_module.add_src_file([

View File

@ -28,7 +28,7 @@ def configure(target, my_module):
my_module.add_path(".")
my_module.add_depend([
'enet',
'gtest',
'etest',
'test-debug'
])
my_module.add_src_file([

View File

@ -28,7 +28,7 @@ def configure(target, my_module):
my_module.add_path(".")
my_module.add_depend([
'enet',
'gtest',
'etest',
'test-debug'
])
my_module.add_src_file([

View File

@ -28,7 +28,7 @@ def configure(target, my_module):
my_module.add_path(".")
my_module.add_depend([
'enet',
'gtest',
'etest',
'test-debug'
])
my_module.add_src_file([

View File

@ -28,7 +28,7 @@ def configure(target, my_module):
my_module.add_path(".")
my_module.add_depend([
'enet',
'gtest',
'etest',
'test-debug'
])
my_module.add_src_file([