Skip to content

Commit

Permalink
Refactor beast::asio:
Browse files Browse the repository at this point in the history
* New tools for completion handlers:
  - wrap_handler provides composed io_service execution guarantees.
  - bind_handler rebinds arguments to handlers.
  - shared_handler type-erases any completion handler.
  - buffer_sequence type-erases templated BufferSequences
  - abstract_socket replaces Socket
  - socket_wrapper replaces SocketWrapper
  - beast::asio placeholders to work with std::bind

* Removed obsolete classes and functions
  - AbstractHandler
  - ComposedAsyncOperation
  - SharedFunction
  - SharedHandler
  - SharedHandlerAllocator
  - SharedHandlerPtr
  - SharedHandlerType
  - SocketBase
  - SocketWrapperStrand
  - wrapHandler

* Refactored classes to use new tools
  - abstract_socket
  - socket_wrapper
  - HandshakeDetector
  - HttpClientType

* Miscellanous tidying
  - socket classes moved to beast::asio namespace
  - beast asio files provide their own namespace declaration.
  - Fix IsCallPossible conflicting template parameter name
  - Use <boost/get_pointer.hpp> for C++11 compatibility.
  - Remove extraneous include path from build environment.
  • Loading branch information
vinniefalco committed Mar 14, 2014
1 parent e3c1375 commit c2fd121
Show file tree
Hide file tree
Showing 161 changed files with 3,138 additions and 3,786 deletions.
2 changes: 1 addition & 1 deletion Builds/QtCreator/rippled.pro
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ linux-g++:QMAKE_CXXFLAGS += \
-pthread

INCLUDEPATH += \
"../../src" \
"../../src/BeastConfig/" \
"../../src/leveldb/" \
"../../src/leveldb/port" \
"../../src/leveldb/include" \
Expand Down
2 changes: 1 addition & 1 deletion Builds/VisualStudio2013/RippleD.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PreprocessorDefinitions>_VARIADIC_MAX=10;_WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(RepoDir)\src\protobuf\src;$(RepoDir)\src\protobuf\vsprojects;$(RepoDir)\src;$(RepoDir)\src\leveldb;$(RepoDir)\src\leveldb\include;$(RepoDir)\build\proto;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(RepoDir)\src\BeastConfig;$(RepoDir)\src\protobuf\src;$(RepoDir)\src\protobuf\vsprojects;$(RepoDir)\src\leveldb;$(RepoDir)\src\leveldb\include;$(RepoDir)\build\proto;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<ExceptionHandling>Async</ExceptionHandling>
<DisableSpecificWarnings>4018;4244</DisableSpecificWarnings>
Expand Down
2 changes: 1 addition & 1 deletion Builds/VisualStudio2013/RippleD.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,7 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\BeastConfig\BeastConfig.h" />
<ClInclude Include="..\..\src\ripple\algorithm\api\CycledSet.h" />
<ClInclude Include="..\..\src\ripple\algorithm\api\DecayingSample.h" />
<ClInclude Include="..\..\src\ripple\common\byte_view.h" />
Expand Down Expand Up @@ -2663,7 +2664,6 @@
<ClInclude Include="..\..\src\ripple_rpc\ripple_rpc.h" />
<ClInclude Include="..\..\src\ripple_websocket\autosocket\AutoSocket.h" />
<ClInclude Include="..\..\src\ripple_websocket\ripple_websocket.h" />
<ClInclude Include="..\..\src\BeastConfig.h" />
<ClInclude Include="..\..\src\leveldb\db\builder.h" />
<ClInclude Include="..\..\src\leveldb\db\dbformat.h" />
<ClInclude Include="..\..\src\leveldb\db\db_impl.h" />
Expand Down
1 change: 0 additions & 1 deletion Builds/VisualStudio2013/RippleD.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,6 @@
<ClInclude Include="..\..\src\ripple_app\misc\Validations.h">
<Filter>[2] Old Ripple\ripple_app\misc</Filter>
</ClInclude>
<ClInclude Include="..\..\src\BeastConfig.h" />
<ClInclude Include="..\..\src\ripple_core\functional\Config.h">
<Filter>[2] Old Ripple\ripple_core\functional</Filter>
</ClInclude>
Expand Down
3 changes: 1 addition & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,10 @@ else:
#
INCLUDE_PATHS = [
'.',
'src',
'src/BeastConfig',
'src/leveldb',
'src/leveldb/port',
'src/leveldb/include',
'src/beast',
'build/proto'
]

Expand Down
File renamed without changes.
44 changes: 14 additions & 30 deletions src/beast/Builds/VisualStudio2013/beast.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,15 @@
<ItemGroup>
<ClInclude Include="..\..\beast\Arithmetic.h" />
<ClInclude Include="..\..\beast\Asio.h" />
<ClInclude Include="..\..\beast\asio\abstract_socket.h" />
<ClInclude Include="..\..\beast\asio\bind_handler.h" />
<ClInclude Include="..\..\beast\asio\buffer_sequence.h" />
<ClInclude Include="..\..\beast\asio\io_latency_probe.h" />
<ClInclude Include="..\..\beast\asio\IPAddressConversion.h" />
<ClInclude Include="..\..\beast\asio\placeholders.h" />
<ClInclude Include="..\..\beast\asio\shared_handler.h" />
<ClInclude Include="..\..\beast\asio\socket_wrapper.h" />
<ClInclude Include="..\..\beast\asio\wrap_handler.h" />
<ClInclude Include="..\..\beast\Atomic.h" />
<ClInclude Include="..\..\beast\Boost.h" />
<ClInclude Include="..\..\beast\boost\ErrorCode.h" />
Expand Down Expand Up @@ -150,6 +157,7 @@
<ClInclude Include="..\..\beast\HeapBlock.h" />
<ClInclude Include="..\..\beast\HTTP.h" />
<ClInclude Include="..\..\beast\http\impl\http-parser\http_parser.h" />
<ClInclude Include="..\..\beast\http\impl\http_parser.h" />
<ClInclude Include="..\..\beast\http\ParsedURL.h" />
<ClInclude Include="..\..\beast\http\URL.h" />
<ClInclude Include="..\..\beast\Insight.h" />
Expand Down Expand Up @@ -238,15 +246,7 @@
<ClInclude Include="..\..\beast\utility\StaticObject.h" />
<ClInclude Include="..\..\beast\Version.h" />
<ClInclude Include="..\..\config\BeastConfig.h" />
<ClInclude Include="..\..\modules\beast_asio\async\AbstractHandler.h" />
<ClInclude Include="..\..\modules\beast_asio\async\AsyncObject.h" />
<ClInclude Include="..\..\modules\beast_asio\async\ComposedAsyncOperation.h" />
<ClInclude Include="..\..\modules\beast_asio\async\WrapHandler.h" />
<ClInclude Include="..\..\modules\beast_asio\async\SharedHandler.h" />
<ClInclude Include="..\..\modules\beast_asio\async\SharedHandlerAllocator.h" />
<ClInclude Include="..\..\modules\beast_asio\async\SharedHandlerPtr.h" />
<ClInclude Include="..\..\modules\beast_asio\async\SharedHandlerType.h" />
<ClInclude Include="..\..\modules\beast_asio\basics\BuffersType.h" />
<ClInclude Include="..\..\modules\beast_asio\basics\FixedInputBuffer.h" />
<ClInclude Include="..\..\modules\beast_asio\basics\PeerRole.h" />
<ClInclude Include="..\..\modules\beast_asio\basics\SharedArg.h" />
Expand All @@ -270,9 +270,6 @@
<ClInclude Include="..\..\modules\beast_asio\protocol\HandshakeDetector.h" />
<ClInclude Include="..\..\modules\beast_asio\protocol\InputParser.h" />
<ClInclude Include="..\..\modules\beast_asio\protocol\PrefilledReadStream.h" />
<ClInclude Include="..\..\modules\beast_asio\sockets\Socket.h" />
<ClInclude Include="..\..\modules\beast_asio\sockets\SocketBase.h" />
<ClInclude Include="..\..\modules\beast_asio\sockets\SocketWrapper.h" />
<ClInclude Include="..\..\modules\beast_asio\system\BoostIncludes.h" />
<ClInclude Include="..\..\modules\beast_asio\system\OpenSSLIncludes.h" />
<ClInclude Include="..\..\modules\beast_asio\tests\TestPeer.h" />
Expand Down Expand Up @@ -325,7 +322,6 @@
<ClInclude Include="..\..\modules\beast_core\memory\MemoryAlignment.h" />
<ClInclude Include="..\..\modules\beast_core\memory\MemoryBlock.h" />
<ClInclude Include="..\..\modules\beast_core\memory\OptionalScopedPointer.h" />
<ClInclude Include="..\..\modules\beast_core\memory\SharedFunction.h" />
<ClInclude Include="..\..\modules\beast_core\memory\SharedSingleton.h" />
<ClInclude Include="..\..\modules\beast_core\misc\Main.h" />
<ClInclude Include="..\..\modules\beast_core\misc\Result.h" />
Expand Down Expand Up @@ -424,6 +420,12 @@
<ClInclude Include="..\..\modules\beast_sqlite\sqlite\sqlite3ext.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\beast\asio\abstract_socket.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\beast\asio\Asio.cpp" />
<ClCompile Include="..\..\beast\asio\impl\IPAddressConversion.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
Expand Down Expand Up @@ -743,12 +745,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\beast\utility\Utility.cpp" />
<ClCompile Include="..\..\modules\beast_asio\async\SharedHandler.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_asio\basics\PeerRole.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
Expand Down Expand Up @@ -826,18 +822,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_asio\sockets\Socket.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_asio\sockets\SocketBase.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\beast_asio\system\BoostUnitTests.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
Expand Down
75 changes: 27 additions & 48 deletions src/beast/Builds/VisualStudio2013/beast.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@
<Filter Include="beast_asio">
<UniqueIdentifier>{54bbe439-76c3-4781-becc-9c70a2be6d82}</UniqueIdentifier>
</Filter>
<Filter Include="beast_asio\sockets">
<UniqueIdentifier>{af535ad5-a06c-462f-8ac0-8207a708e032}</UniqueIdentifier>
</Filter>
<Filter Include="beast_asio\system">
<UniqueIdentifier>{c7a576bb-27b2-486e-aa14-3c51aa86c50f}</UniqueIdentifier>
</Filter>
Expand Down Expand Up @@ -710,36 +707,12 @@
<ClInclude Include="..\..\modules\beast_core\system\SystemStats.h">
<Filter>beast_core\system</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\async\ComposedAsyncOperation.h">
<Filter>beast_asio\async</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\async\SharedHandler.h">
<Filter>beast_asio\async</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\async\SharedHandlerAllocator.h">
<Filter>beast_asio\async</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\async\SharedHandlerPtr.h">
<Filter>beast_asio\async</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\async\SharedHandlerType.h">
<Filter>beast_asio\async</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\basics\FixedInputBuffer.h">
<Filter>beast_asio\basics</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\basics\PeerRole.h">
<Filter>beast_asio\basics</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\sockets\Socket.h">
<Filter>beast_asio\sockets</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\sockets\SocketBase.h">
<Filter>beast_asio\sockets</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\sockets\SocketWrapper.h">
<Filter>beast_asio\sockets</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\system\OpenSSLIncludes.h">
<Filter>beast_asio\system</Filter>
</ClInclude>
Expand Down Expand Up @@ -824,9 +797,6 @@
<ClInclude Include="..\..\modules\beast_asio\http\HTTPParserImpl.h">
<Filter>beast_asio\http</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\basics\BuffersType.h">
<Filter>beast_asio\basics</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\memory\SharedSingleton.h">
<Filter>beast_core\memory</Filter>
</ClInclude>
Expand All @@ -839,9 +809,6 @@
<ClInclude Include="..\..\modules\beast_core\diagnostic\FatalError.h">
<Filter>beast_core\diagnostic</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_core\memory\SharedFunction.h">
<Filter>beast_core\memory</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\Config.h">
<Filter>beast</Filter>
</ClInclude>
Expand Down Expand Up @@ -986,12 +953,6 @@
<ClInclude Include="..\..\beast\crypto\Sha256.h">
<Filter>beast\crypto</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\async\WrapHandler.h">
<Filter>beast_asio\async</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_asio\async\AbstractHandler.h">
<Filter>beast_asio\async</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\Chrono.h">
<Filter>beast</Filter>
</ClInclude>
Expand Down Expand Up @@ -1338,6 +1299,30 @@
<ClInclude Include="..\..\beast\cxx14\utility.h">
<Filter>beast\cxx14</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\asio\abstract_socket.h">
<Filter>beast\asio</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\asio\bind_handler.h">
<Filter>beast\asio</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\asio\buffer_sequence.h">
<Filter>beast\asio</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\asio\placeholders.h">
<Filter>beast\asio</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\asio\shared_handler.h">
<Filter>beast\asio</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\asio\socket_wrapper.h">
<Filter>beast\asio</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\asio\wrap_handler.h">
<Filter>beast\asio</Filter>
</ClInclude>
<ClInclude Include="..\..\beast\http\impl\http_parser.h">
<Filter>beast\http\impl</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\modules\beast_core\containers\DynamicObject.cpp">
Expand Down Expand Up @@ -1649,18 +1634,9 @@
<ClCompile Include="..\..\modules\beast_core\system\SystemStats.cpp">
<Filter>beast_core\system</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_asio\async\SharedHandler.cpp">
<Filter>beast_asio\async</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_asio\basics\PeerRole.cpp">
<Filter>beast_asio\basics</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_asio\sockets\Socket.cpp">
<Filter>beast_asio\sockets</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_asio\sockets\SocketBase.cpp">
<Filter>beast_asio\sockets</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\beast_asio\system\BoostUnitTests.cpp">
<Filter>beast_asio\system</Filter>
</ClCompile>
Expand Down Expand Up @@ -1931,6 +1907,9 @@
<ClCompile Include="..\..\beast\cxx14\tests\integer_sequence.test.cpp">
<Filter>beast\cxx14\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\beast\asio\abstract_socket.cpp">
<Filter>beast\asio</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text Include="..\..\TODO.txt">
Expand Down
2 changes: 0 additions & 2 deletions src/beast/beast/Asio.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@
#ifndef BEAST_ASIO_H_INCLUDED
#define BEAST_ASIO_H_INCLUDED

#include "asio/IPAddressConversion.h"

#endif
6 changes: 6 additions & 0 deletions src/beast/beast/asio/Asio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@
#include "BeastConfig.h"

#include "impl/IPAddressConversion.cpp"

#include "tests/wrap_handler_tests.cpp"
#include "tests/bind_handler_tests.cpp"
#include "tests/shared_handler_tests.cpp"

#include "abstract_socket.cpp" // TEMPORARY!
Loading

0 comments on commit c2fd121

Please sign in to comment.