Skip to content

Commit

Permalink
remove BrynetAnyBRYNET_NOEXCEPT。 (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
IronsDu authored Aug 25, 2024
1 parent 337c9f3 commit 22c761b
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 125 deletions.
30 changes: 0 additions & 30 deletions include/brynet/base/Any.hpp

This file was deleted.

16 changes: 0 additions & 16 deletions include/brynet/base/CPP_VERSION.hpp

This file was deleted.

9 changes: 0 additions & 9 deletions include/brynet/base/Noexcept.hpp

This file was deleted.

3 changes: 1 addition & 2 deletions include/brynet/base/Timer.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <atomic>
#include <brynet/base/Noexcept.hpp>
#include <chrono>
#include <functional>
#include <memory>
Expand All @@ -22,7 +21,7 @@ class Timer final

Timer(std::chrono::steady_clock::time_point startTime,
std::chrono::nanoseconds lastTime,
Callback&& callback) BRYNET_NOEXCEPT
Callback&& callback)
: mCallback(std::move(callback)),
mStartTime(startTime),
mLastTime(lastTime)
Expand Down
14 changes: 6 additions & 8 deletions include/brynet/net/EventLoop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <algorithm>
#include <atomic>
#include <brynet/base/Noexcept.hpp>
#include <brynet/base/NonCopyable.hpp>
#include <brynet/base/Timer.hpp>
#include <brynet/net/Channel.hpp>
Expand Down Expand Up @@ -33,15 +32,14 @@ class EventLoop : public brynet::base::NonCopyable

public:
EventLoop()
BRYNET_NOEXCEPT
:
#ifdef BRYNET_PLATFORM_WINDOWS
mIOCP(CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 1)),
mWakeupChannel(std::make_unique<detail::WakeupChannel>(mIOCP))
mIOCP(CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 1)),
mWakeupChannel(std::make_unique<detail::WakeupChannel>(mIOCP))
#elif defined BRYNET_PLATFORM_LINUX
mEpollFd(epoll_create(1))
mEpollFd(epoll_create(1))
#elif defined BRYNET_PLATFORM_DARWIN || defined BRYNET_PLATFORM_FREEBSD
mKqueueFd(kqueue())
mKqueueFd(kqueue())
#endif
{
#ifdef BRYNET_PLATFORM_WINDOWS
Expand Down Expand Up @@ -82,7 +80,7 @@ class EventLoop : public brynet::base::NonCopyable
mSelfThreadIDIsInitialized.store(false);
}

virtual ~EventLoop() BRYNET_NOEXCEPT
virtual ~EventLoop()
{
#ifdef BRYNET_PLATFORM_WINDOWS
CloseHandle(mIOCP);
Expand Down Expand Up @@ -389,7 +387,7 @@ class EventLoop : public brynet::base::NonCopyable
return mKqueueFd;
}
#endif
bool linkChannel(BrynetSocketFD fd, const Channel* ptr) BRYNET_NOEXCEPT
bool linkChannel(BrynetSocketFD fd, const Channel* ptr)
{
#ifdef BRYNET_PLATFORM_WINDOWS
return CreateIoCompletionPort((HANDLE) fd, mIOCP, (ULONG_PTR) ptr, 0) != nullptr;
Expand Down
7 changes: 3 additions & 4 deletions include/brynet/net/SSLHelper.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <brynet/base/Noexcept.hpp>
#include <brynet/base/NonCopyable.hpp>
#include <brynet/base/Platform.hpp>
#include <memory>
Expand Down Expand Up @@ -86,7 +85,7 @@ class SSLHelper : public brynet::base::NonCopyable,
{
std::call_once(initCryptoThreadSafeSupportOnceFlag,
InitCryptoThreadSafeSupport);
}
}

bool initSSL(const std::string& certificate,
const std::string& privatekey)
Expand Down Expand Up @@ -157,14 +156,14 @@ class SSLHelper : public brynet::base::NonCopyable,
}

protected:
SSLHelper() BRYNET_NOEXCEPT
SSLHelper()
{
#ifdef BRYNET_USE_OPENSSL
mOpenSSLCTX = nullptr;
#endif
}

virtual ~SSLHelper() BRYNET_NOEXCEPT
virtual ~SSLHelper()
{
#ifdef BRYNET_USE_OPENSSL
destroySSL();
Expand Down
28 changes: 13 additions & 15 deletions include/brynet/net/TcpConnection.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once

#include <brynet/base/Any.hpp>
#include <brynet/base/Buffer.hpp>
#include <brynet/base/Noexcept.hpp>
#include <brynet/base/NonCopyable.hpp>
#include <brynet/base/Packet.hpp>
#include <brynet/base/Timer.hpp>
Expand Down Expand Up @@ -240,21 +238,21 @@ class TcpConnection : public Channel,
TcpConnection(TcpSocket::Ptr socket,
size_t maxRecvBufferSize,
EnterCallback&& enterCallback,
EventLoop::Ptr eventLoop) BRYNET_NOEXCEPT
EventLoop::Ptr eventLoop)
:
#ifdef BRYNET_PLATFORM_WINDOWS
mOvlRecv(port::Win::OverlappedType::OverlappedRecv),
mOvlSend(port::Win::OverlappedType::OverlappedSend),
mPostClose(false),
mOvlRecv(port::Win::OverlappedType::OverlappedRecv),
mOvlSend(port::Win::OverlappedType::OverlappedSend),
mPostClose(false),
#endif
mIP(socket->getRemoteIP()),
mSocket(std::move(socket)),
mEventLoop(std::move(eventLoop)),
mAlreadyClose(false),
mMaxRecvBufferSize(maxRecvBufferSize),
mSendingMsgSize(0),
mEnterCallback(std::move(enterCallback)),
mHighWaterSize(0)
mIP(socket->getRemoteIP()),
mSocket(std::move(socket)),
mEventLoop(std::move(eventLoop)),
mAlreadyClose(false),
mMaxRecvBufferSize(maxRecvBufferSize),
mSendingMsgSize(0),
mEnterCallback(std::move(enterCallback)),
mHighWaterSize(0)
{
mRecvData = false;
mCheckTime = std::chrono::steady_clock::duration::zero();
Expand All @@ -275,7 +273,7 @@ class TcpConnection : public Channel,
#endif
}

~TcpConnection() BRYNET_NOEXCEPT override
~TcpConnection() override
{
#ifdef BRYNET_USE_OPENSSL
if (mSSL != nullptr)
Expand Down
24 changes: 1 addition & 23 deletions include/brynet/net/detail/ConnectorDetail.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
#pragma once

#include <brynet/base/CPP_VERSION.hpp>
#include <brynet/base/NonCopyable.hpp>
#include <brynet/base/WaitGroup.hpp>
#include <brynet/net/EventLoop.hpp>
#include <brynet/net/Exception.hpp>
#include <brynet/net/detail/ConnectorWorkInfo.hpp>
#include <functional>
#include <memory>
#include <thread>

#ifdef BRYNET_HAVE_LANG_CXX17
#include <shared_mutex>
#else
#include <mutex>
#endif
#include <thread>

namespace brynet { namespace net { namespace detail {

Expand All @@ -23,11 +17,7 @@ class AsyncConnectorDetail : public brynet::base::NonCopyable
protected:
void startWorkerThread()
{
#ifdef BRYNET_HAVE_LANG_CXX17
std::lock_guard<std::shared_mutex> lck(mThreadGuard);
#else
std::lock_guard<std::mutex> lck(mThreadGuard);
#endif

if (mThread != nullptr)
{
Expand Down Expand Up @@ -61,11 +51,7 @@ class AsyncConnectorDetail : public brynet::base::NonCopyable

void stopWorkerThread()
{
#ifdef BRYNET_HAVE_LANG_CXX17
std::lock_guard<std::shared_mutex> lck(mThreadGuard);
#else
std::lock_guard<std::mutex> lck(mThreadGuard);
#endif

if (mThread == nullptr)
{
Expand Down Expand Up @@ -96,11 +82,7 @@ class AsyncConnectorDetail : public brynet::base::NonCopyable

void asyncConnect(detail::ConnectOption option)
{
#ifdef BRYNET_HAVE_LANG_CXX17
std::shared_lock<std::shared_mutex> lck(mThreadGuard);
#else
std::lock_guard<std::mutex> lck(mThreadGuard);
#endif

if (option.completedCallback == nullptr && option.failedCallback == nullptr)
{
Expand Down Expand Up @@ -144,11 +126,7 @@ class AsyncConnectorDetail : public brynet::base::NonCopyable

std::shared_ptr<detail::ConnectorWorkInfo> mWorkInfo;
std::shared_ptr<std::thread> mThread;
#ifdef BRYNET_HAVE_LANG_CXX17
std::shared_mutex mThreadGuard;
#else
std::mutex mThreadGuard;
#endif
std::shared_ptr<bool> mIsRun;
};

Expand Down
10 changes: 2 additions & 8 deletions include/brynet/net/detail/ConnectorWorkInfo.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
#pragma once

#include <brynet/base/CPP_VERSION.hpp>
#include <brynet/base/NonCopyable.hpp>
#include <brynet/net/Poller.hpp>
#include <brynet/net/Socket.hpp>
#include <brynet/net/SocketLibTypes.hpp>
#include <functional>
#include <map>
#include <memory>
#include <set>

#ifdef BRYNET_HAVE_LANG_CXX17
#include <shared_mutex>
#else
#include <mutex>
#endif
#include <set>

namespace brynet { namespace net { namespace detail {

Expand Down Expand Up @@ -85,7 +79,7 @@ class ConnectorWorkInfo final : public brynet::base::NonCopyable
public:
using Ptr = std::shared_ptr<ConnectorWorkInfo>;

ConnectorWorkInfo() BRYNET_NOEXCEPT
ConnectorWorkInfo()
{
mPoller.reset(brynet::base::poller_new());
mPollResult.reset(brynet::base::stack_new(1024, sizeof(BrynetSocketFD)));
Expand Down
3 changes: 1 addition & 2 deletions include/brynet/net/detail/ListenThreadDetail.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <brynet/base/Noexcept.hpp>
#include <brynet/base/NonCopyable.hpp>
#include <brynet/net/AsyncConnector.hpp>
#include <brynet/net/Socket.hpp>
Expand Down Expand Up @@ -128,7 +127,7 @@ class ListenThreadDetail : public brynet::base::NonCopyable
mRunListen = std::make_shared<bool>(false);
}

virtual ~ListenThreadDetail() BRYNET_NOEXCEPT
virtual ~ListenThreadDetail()
{
stopListen();
}
Expand Down
5 changes: 2 additions & 3 deletions include/brynet/net/detail/TCPServiceDetail.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <brynet/base/Noexcept.hpp>
#include <brynet/base/NonCopyable.hpp>
#include <brynet/base/WaitGroup.hpp>
#include <brynet/net/SSLHelper.hpp>
Expand Down Expand Up @@ -53,14 +52,14 @@ class TcpServiceDetail : public brynet::base::NonCopyable
using FrameCallback = std::function<void(const EventLoop::Ptr&)>;
const static unsigned int sDefaultLoopTimeOutMS = 100;

TcpServiceDetail() BRYNET_NOEXCEPT
TcpServiceDetail()
: mRandom(static_cast<unsigned int>(
std::chrono::system_clock::now().time_since_epoch().count()))
{
mRunIOLoop = std::make_shared<bool>(false);
}

virtual ~TcpServiceDetail() BRYNET_NOEXCEPT
virtual ~TcpServiceDetail()
{
stopWorkerThread();
}
Expand Down
8 changes: 4 additions & 4 deletions include/brynet/net/detail/WakeupChannel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class WakeupChannel final : public Channel, public brynet::base::NonCopyable
{
}

bool wakeup() BRYNET_NOEXCEPT
bool wakeup()
{
return PostQueuedCompletionStatus(mIOCP,
0,
Expand All @@ -29,17 +29,17 @@ class WakeupChannel final : public Channel, public brynet::base::NonCopyable
}

private:
void canRecv(bool) BRYNET_NOEXCEPT override
void canRecv(bool) override
{
;
}

void canSend() BRYNET_NOEXCEPT override
void canSend() override
{
;
}

void onClose() BRYNET_NOEXCEPT override
void onClose() override
{
;
}
Expand Down
3 changes: 2 additions & 1 deletion include/brynet/net/port/Win.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class Win
OVERLAPPED base;
const OverlappedType OP;

OverlappedExt(OverlappedType op) BRYNET_NOEXCEPT : OP(op)
OverlappedExt(OverlappedType op)
: OP(op)
{
memset(&base, 0, sizeof(base));
}
Expand Down

0 comments on commit 22c761b

Please sign in to comment.