mirror of
https://github.com/oatpp/oatpp.git
synced 2025-01-18 16:43:57 +08:00
commit
9b1d816d5e
@ -57,11 +57,8 @@ add_library(oatpp
|
||||
oatpp/core/base/memory/MemoryPool.hpp
|
||||
oatpp/core/base/memory/ObjectPool.cpp
|
||||
oatpp/core/base/memory/ObjectPool.hpp
|
||||
oatpp/core/collection/FastQueue.cpp
|
||||
oatpp/core/collection/FastQueue.hpp
|
||||
oatpp/core/collection/LinkedList.cpp
|
||||
oatpp/core/collection/LinkedList.hpp
|
||||
oatpp/core/collection/ListMap.cpp
|
||||
oatpp/core/collection/ListMap.hpp
|
||||
oatpp/core/concurrency/SpinLock.cpp
|
||||
oatpp/core/concurrency/SpinLock.hpp
|
||||
|
@ -1,26 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* Project _____ __ ____ _ _
|
||||
* ( _ ) /__\ (_ _)_| |_ _| |_
|
||||
* )(_)( /(__)\ )( (_ _)(_ _)
|
||||
* (_____)(__)(__)(__) |_| |_|
|
||||
*
|
||||
*
|
||||
* Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "FastQueue.hpp"
|
||||
|
@ -1,26 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* Project _____ __ ____ _ _
|
||||
* ( _ ) /__\ (_ _)_| |_ _| |_
|
||||
* )(_)( /(__)\ )( (_ _)(_ _)
|
||||
* (_____)(__)(__)(__) |_| |_|
|
||||
*
|
||||
*
|
||||
* Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "LinkedList.hpp"
|
||||
|
@ -85,29 +85,6 @@ private:
|
||||
node->~LinkedListNode();
|
||||
oatpp::base::memory::MemoryPool::free(node);
|
||||
}
|
||||
|
||||
LinkedListNode* getNode(v_int32 index) const{
|
||||
|
||||
if(index >= m_count){
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
v_int32 i = 0;
|
||||
LinkedListNode* curr = m_first;
|
||||
|
||||
while(curr != nullptr){
|
||||
|
||||
if(i == index){
|
||||
return curr;
|
||||
}
|
||||
|
||||
curr = curr->next;
|
||||
i++;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@ -218,6 +195,29 @@ public:
|
||||
throw std::runtime_error("[oatpp::collection::LinkedList::get(index)]: index out of bounds");
|
||||
|
||||
}
|
||||
|
||||
LinkedListNode* getNode(v_int32 index) const {
|
||||
|
||||
if(index >= m_count){
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
v_int32 i = 0;
|
||||
LinkedListNode* curr = m_first;
|
||||
|
||||
while(curr != nullptr){
|
||||
|
||||
if(i == index){
|
||||
return curr;
|
||||
}
|
||||
|
||||
curr = curr->next;
|
||||
i++;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
LinkedListNode* getFirstNode() const {
|
||||
return m_first;
|
||||
|
@ -1,26 +0,0 @@
|
||||
/***************************************************************************
|
||||
*
|
||||
* Project _____ __ ____ _ _
|
||||
* ( _ ) /__\ (_ _)_| |_ _| |_
|
||||
* )(_)( /(__)\ )( (_ _)(_ _)
|
||||
* (_____)(__)(__)(__) |_| |_|
|
||||
*
|
||||
*
|
||||
* Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "ListMap.hpp"
|
||||
|
@ -25,12 +25,13 @@
|
||||
#include "./Connection.hpp"
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#include <io.h>
|
||||
#include <WinSock2.h>
|
||||
#include <io.h>
|
||||
#include <WinSock2.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <fcntl.h>
|
||||
@ -152,24 +153,25 @@ data::v_io_size Connection::read(void *buff, v_buff_size count){
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
void Connection::setStreamIOMode(oatpp::data::stream::IOMode ioMode) {
|
||||
|
||||
u_long flags;
|
||||
u_long flags;
|
||||
|
||||
switch(ioMode) {
|
||||
case data::stream::BLOCKING:
|
||||
flags = 0;
|
||||
if(NO_ERROR != ioctlsocket(m_handle, FIONBIO, &flags)) {
|
||||
throw std::runtime_error("[oatpp::network::Connection::setStreamIOMode()]: Error. Can't set stream I/O mode to IOMode::BLOCKING.");
|
||||
}
|
||||
m_mode = data::stream::BLOCKING;
|
||||
break;
|
||||
case data::stream::NON_BLOCKING:
|
||||
flags = 1;
|
||||
if(NO_ERROR != ioctlsocket(m_handle, FIONBIO, &flags)) {
|
||||
throw std::runtime_error("[oatpp::network::Connection::setStreamIOMode()]: Error. Can't set stream I/O mode to IOMode::NON_BLOCKING.");
|
||||
}
|
||||
m_mode = data::stream::NON_BLOCKING;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(ioMode) {
|
||||
case data::stream::BLOCKING:
|
||||
flags = 0;
|
||||
if(NO_ERROR != ioctlsocket(m_handle, FIONBIO, &flags)) {
|
||||
throw std::runtime_error("[oatpp::network::Connection::setStreamIOMode()]: Error. Can't set stream I/O mode to IOMode::BLOCKING.");
|
||||
}
|
||||
m_mode = data::stream::BLOCKING;
|
||||
break;
|
||||
case data::stream::NON_BLOCKING:
|
||||
flags = 1;
|
||||
if(NO_ERROR != ioctlsocket(m_handle, FIONBIO, &flags)) {
|
||||
throw std::runtime_error("[oatpp::network::Connection::setStreamIOMode()]: Error. Can't set stream I/O mode to IOMode::NON_BLOCKING.");
|
||||
}
|
||||
m_mode = data::stream::NON_BLOCKING;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void Connection::setStreamIOMode(oatpp::data::stream::IOMode ioMode) {
|
||||
@ -201,7 +203,7 @@ void Connection::setStreamIOMode(oatpp::data::stream::IOMode ioMode) {
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
oatpp::data::stream::IOMode Connection::getStreamIOMode() {
|
||||
return m_mode;
|
||||
return m_mode;
|
||||
}
|
||||
#else
|
||||
oatpp::data::stream::IOMode Connection::getStreamIOMode() {
|
||||
@ -233,7 +235,7 @@ oatpp::async::Action Connection::suggestOutputStreamAction(data::v_io_size ioRes
|
||||
return oatpp::async::Action::createIORepeatAction(m_handle, oatpp::async::Action::IOEventType::IO_EVENT_WRITE);
|
||||
}
|
||||
|
||||
throw std::runtime_error("[oatpp::network::virtual_::Pipe::Reader::suggestInputStreamAction()]: Error. Unable to suggest async action for I/O result.");
|
||||
throw std::runtime_error("[oatpp::network::Connection::suggestInputStreamAction()]: Error. Unable to suggest async action for I/O result.");
|
||||
|
||||
}
|
||||
|
||||
@ -250,7 +252,7 @@ oatpp::async::Action Connection::suggestInputStreamAction(data::v_io_size ioResu
|
||||
return oatpp::async::Action::createIORepeatAction(m_handle, oatpp::async::Action::IOEventType::IO_EVENT_READ);
|
||||
}
|
||||
|
||||
throw std::runtime_error("[oatpp::network::virtual_::Pipe::Reader::suggestInputStreamAction()]: Error. Unable to suggest async action for I/O result.");
|
||||
throw std::runtime_error("[oatpp::network::Connection::suggestInputStreamAction()]: Error. Unable to suggest async action for I/O result.");
|
||||
|
||||
|
||||
}
|
||||
|
@ -29,15 +29,16 @@
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#include <io.h>
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <io.h>
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#else
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace oatpp { namespace network { namespace client {
|
||||
|
@ -25,20 +25,20 @@
|
||||
#include "./SimpleTCPConnectionProvider.hpp"
|
||||
|
||||
#include "oatpp/network/Connection.hpp"
|
||||
|
||||
#include "oatpp/core/utils/ConversionUtils.hpp"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#include <io.h>
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <io.h>
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#else
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace oatpp { namespace network { namespace server {
|
||||
|
Loading…
Reference in New Issue
Block a user