From 911f22508e921c6077e8156892622ad32a928b6d Mon Sep 17 00:00:00 2001 From: aleks-f Date: Thu, 31 Jan 2013 21:12:13 -0600 Subject: [PATCH] Any SOO --- .../ApacheConnector_x64_vs100.vcxproj | 86 +-- Crypto/testsuite/TestSuite_x64_vs100.vcxproj | 162 +++--- Foundation/Foundation_CE_vs90.vcproj | 8 + Foundation/Foundation_vs100.vcxproj | 2 + Foundation/Foundation_vs100.vcxproj.filters | 6 + Foundation/Foundation_vs110.vcxproj | 2 + Foundation/Foundation_vs110.vcxproj.filters | 6 + Foundation/Foundation_vs71.vcproj | 9 + Foundation/Foundation_vs80.vcproj | 12 + Foundation/Foundation_vs90.vcproj | 12 + Foundation/Foundation_x64_vs100.vcxproj | 15 +- .../Foundation_x64_vs100.vcxproj.filters | 9 + Foundation/Foundation_x64_vs110.vcxproj | 3 + .../Foundation_x64_vs110.vcxproj.filters | 9 + Foundation/Foundation_x64_vs90.vcproj | 12 + Foundation/include/Poco/Any.h | 228 +++++++- Foundation/include/Poco/Config.h | 6 + .../include/Poco/SmallObjectAllocator.h | 251 +++++++++ Foundation/include/Poco/Types.h | 11 + Foundation/src/FIFOBufferStream.cpp | 4 +- .../testsuite/TestApp_x64_vs100.vcxproj | 12 +- .../testsuite/TestLibrary_x64_vs100.vcxproj | 4 +- .../testsuite/TestSuite_x64_vs100.vcxproj | 12 +- Foundation/testsuite/src/AnyTest.cpp | 3 + Foundation/testsuite/src/CoreTest.cpp | 165 ++++++ Foundation/testsuite/src/CoreTest.h | 1 + Net/Net_CE_vs90.vcproj | 4 + Net/Net_vs110.vcxproj | 2 + Net/Net_vs110.vcxproj.filters | 6 + Net/Net_vs71.vcproj | 4 + Net/Net_vs80.vcproj | 4 + Net/Net_vs90.vcproj | 4 + Net/Net_x64_vs100.vcxproj | 512 +++++++++--------- Net/Net_x64_vs100.vcxproj.filters | 6 + Net/Net_x64_vs110.vcxproj | 2 + Net/Net_x64_vs110.vcxproj.filters | 6 + Net/Net_x64_vs90.vcproj | 4 + Net/include/Poco/Net/Net.h | 20 - Net/include/Poco/Net/SocketDefs.h | 21 + Net/src/StreamSocket.cpp | 4 +- Net/testsuite/src/WebSocketTest.cpp | 10 +- Util/Util_vs100.vcxproj | 255 ++++----- Util/Util_vs100.vcxproj.filters | 3 + 43 files changed, 1345 insertions(+), 572 deletions(-) create mode 100644 Foundation/include/Poco/SmallObjectAllocator.h diff --git a/ApacheConnector/ApacheConnector_x64_vs100.vcxproj b/ApacheConnector/ApacheConnector_x64_vs100.vcxproj index 1fcb7634f..2583983fb 100644 --- a/ApacheConnector/ApacheConnector_x64_vs100.vcxproj +++ b/ApacheConnector/ApacheConnector_x64_vs100.vcxproj @@ -1,4 +1,4 @@ - + @@ -16,40 +16,40 @@ ApacheConnector Win32Proj - - + + DynamicLibrary MultiByte - + DynamicLibrary MultiByte - - - - + + + + - - + + - + <_ProjectFileVersion>10.0.40219.1 - ..\bin64\ - obj64\$(Configuration)\ - true - ..\bin64\ - obj64\$(Configuration)\ - false - mod_poco64d - mod_poco64 + ..\bin64\ + obj64\$(Configuration)\ + true + ..\bin64\ + obj64\$(Configuration)\ + false + mod_poco64d + mod_poco64 - + Disabled .\include;..\Foundation\include;..\Net\include;..\Util\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;ApacheHandlers_EXPORTS;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;_USRDLL;ApacheHandlers_EXPORTS;%(PreprocessorDefinitions) true true EnableFastChecks @@ -58,7 +58,7 @@ true true true - + Level3 ProgramDatabase Default @@ -76,7 +76,7 @@ MachineX64 - + Disabled OnlyExplicitInline @@ -84,16 +84,16 @@ Speed true .\include;..\Foundation\include;..\Net\include;..\Util\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;ApacheHandlers_EXPORTS;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;ApacheHandlers_EXPORTS;%(PreprocessorDefinitions) true MultiThreadedDLL false true true true - + Level3 - + Default %(DisableSpecificWarnings) @@ -111,23 +111,23 @@ - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - + + + \ No newline at end of file diff --git a/Crypto/testsuite/TestSuite_x64_vs100.vcxproj b/Crypto/testsuite/TestSuite_x64_vs100.vcxproj index 9b7eadef4..32bde0615 100644 --- a/Crypto/testsuite/TestSuite_x64_vs100.vcxproj +++ b/Crypto/testsuite/TestSuite_x64_vs100.vcxproj @@ -1,4 +1,4 @@ - + @@ -32,90 +32,92 @@ TestSuite Win32Proj - - + + Application Dynamic MultiByte - + Application Dynamic MultiByte - + Application Static MultiByte - + Application Static MultiByte - + Application Dynamic MultiByte - + Application Dynamic MultiByte - - - - + + + + - - + + - - + + - - + + - - + + - - + + - + <_ProjectFileVersion>10.0.40219.1 - bin64\ - obj64\$(Configuration)\ - true - bin64\ - obj64\$(Configuration)\ - false - bin64\static_mt\ - obj64\$(Configuration)\ - true - bin64\static_mt\ - obj64\$(Configuration)\ - false - bin64\static_md\ - obj64\$(Configuration)\ - true - bin64\static_md\ - obj64\$(Configuration)\ - false - TestSuited - TestSuited - TestSuited - TestSuite - TestSuite - TestSuite + bin64\ + obj64\$(Configuration)\ + true + bin64\ + obj64\$(Configuration)\ + false + bin64\static_mt\ + obj64\$(Configuration)\ + true + bin64\static_mt\ + obj64\$(Configuration)\ + false + bin64\static_md\ + obj64\$(Configuration)\ + true + bin64\static_md\ + obj64\$(Configuration)\ + false + TestSuited + TestSuited + TestSuited + TestSuite + TestSuite + TestSuite + C:\openssl\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; + C:\openssl\lib;$(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSdkDir)lib\x64; - + Disabled ..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;WINVER=0x0600;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;WINVER=0x0600;%(PreprocessorDefinitions) true true EnableFastChecks @@ -124,7 +126,7 @@ true true true - + Level3 ProgramDatabase Default @@ -141,7 +143,7 @@ MachineX64 - + Disabled OnlyExplicitInline @@ -149,16 +151,16 @@ Speed true ..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;WINVER=0x0600;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;WINVER=0x0600;%(PreprocessorDefinitions) true MultiThreadedDLL false true true true - + Level3 - + Default %(DisableSpecificWarnings) @@ -173,11 +175,11 @@ MachineX64 - + Disabled ..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) true true EnableFastChecks @@ -186,7 +188,7 @@ true true true - + Level3 ProgramDatabase Default @@ -204,7 +206,7 @@ MachineX64 - + Disabled OnlyExplicitInline @@ -212,16 +214,16 @@ Speed true ..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) true MultiThreaded false true true true - + Level3 - + Default %(DisableSpecificWarnings) @@ -237,11 +239,11 @@ MachineX64 - + Disabled ..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) true true EnableFastChecks @@ -250,7 +252,7 @@ true true true - + Level3 ProgramDatabase Default @@ -267,7 +269,7 @@ MachineX64 - + Disabled OnlyExplicitInline @@ -275,16 +277,16 @@ Speed true ..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) true MultiThreadedDLL false true true true - + Level3 - + Default %(DisableSpecificWarnings) @@ -300,18 +302,18 @@ - - - - + + + + - - - - - + + + + + - - - + + + \ No newline at end of file diff --git a/Foundation/Foundation_CE_vs90.vcproj b/Foundation/Foundation_CE_vs90.vcproj index f3b552211..2c7aac1c2 100644 --- a/Foundation/Foundation_CE_vs90.vcproj +++ b/Foundation/Foundation_CE_vs90.vcproj @@ -6689,6 +6689,10 @@ RelativePath=".\include\Poco\ObjectPool.h" > + + @@ -6721,6 +6725,10 @@ RelativePath=".\include\Poco\SingletonHolder.h" > + + diff --git a/Foundation/Foundation_vs100.vcxproj b/Foundation/Foundation_vs100.vcxproj index a30a67b05..beac537ee 100644 --- a/Foundation/Foundation_vs100.vcxproj +++ b/Foundation/Foundation_vs100.vcxproj @@ -1024,6 +1024,7 @@ + @@ -1033,6 +1034,7 @@ + diff --git a/Foundation/Foundation_vs100.vcxproj.filters b/Foundation/Foundation_vs100.vcxproj.filters index c6f74b470..2821c72c5 100644 --- a/Foundation/Foundation_vs100.vcxproj.filters +++ b/Foundation/Foundation_vs100.vcxproj.filters @@ -1853,6 +1853,12 @@ Streams\Header Files + + Core\Header Files + + + Core\Header Files + diff --git a/Foundation/Foundation_vs110.vcxproj b/Foundation/Foundation_vs110.vcxproj index 30e807248..13fa6ac62 100644 --- a/Foundation/Foundation_vs110.vcxproj +++ b/Foundation/Foundation_vs110.vcxproj @@ -1027,6 +1027,7 @@ + @@ -1036,6 +1037,7 @@ + diff --git a/Foundation/Foundation_vs110.vcxproj.filters b/Foundation/Foundation_vs110.vcxproj.filters index ba3474bac..031b36aaf 100644 --- a/Foundation/Foundation_vs110.vcxproj.filters +++ b/Foundation/Foundation_vs110.vcxproj.filters @@ -1037,6 +1037,9 @@ Core\Header Files + + Core\Header Files + Core\Header Files @@ -1850,6 +1853,9 @@ Core\Header Files + + Core\Header Files + diff --git a/Foundation/Foundation_vs71.vcproj b/Foundation/Foundation_vs71.vcproj index 07e5855b0..6b214fa1e 100644 --- a/Foundation/Foundation_vs71.vcproj +++ b/Foundation/Foundation_vs71.vcproj @@ -904,6 +904,12 @@ + + + + @@ -928,6 +934,9 @@ + + diff --git a/Foundation/Foundation_vs80.vcproj b/Foundation/Foundation_vs80.vcproj index c321e3157..9154b8714 100644 --- a/Foundation/Foundation_vs80.vcproj +++ b/Foundation/Foundation_vs80.vcproj @@ -1207,6 +1207,14 @@ RelativePath=".\include\Poco\NumericString.h" > + + + + @@ -1239,6 +1247,10 @@ RelativePath=".\include\Poco\SingletonHolder.h" > + + diff --git a/Foundation/Foundation_vs90.vcproj b/Foundation/Foundation_vs90.vcproj index 3bb20cf15..d623507b4 100644 --- a/Foundation/Foundation_vs90.vcproj +++ b/Foundation/Foundation_vs90.vcproj @@ -1204,6 +1204,14 @@ RelativePath=".\include\Poco\NumericString.h" > + + + + @@ -1236,6 +1244,10 @@ RelativePath=".\include\Poco\SingletonHolder.h" > + + diff --git a/Foundation/Foundation_x64_vs100.vcxproj b/Foundation/Foundation_x64_vs100.vcxproj index 94b8ceb6a..1829287f9 100644 --- a/Foundation/Foundation_x64_vs100.vcxproj +++ b/Foundation/Foundation_x64_vs100.vcxproj @@ -108,7 +108,7 @@ Disabled .\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;Foundation_EXPORTS;PCRE_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;_USRDLL;Foundation_EXPORTS;PCRE_STATIC;%(PreprocessorDefinitions) true true EnableFastChecks @@ -143,7 +143,7 @@ Speed true .\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;Foundation_EXPORTS;PCRE_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;Foundation_EXPORTS;PCRE_STATIC;%(PreprocessorDefinitions) false false false @@ -183,7 +183,7 @@ Speed true .\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;Foundation_EXPORTS;POCO_STATIC;PCRE_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;Foundation_EXPORTS;POCO_STATIC;PCRE_STATIC;%(PreprocessorDefinitions) false false false @@ -211,7 +211,7 @@ Disabled .\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;Foundation_EXPORTS;POCO_STATIC;PCRE_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;Foundation_EXPORTS;POCO_STATIC;PCRE_STATIC;%(PreprocessorDefinitions) true true EnableFastChecks @@ -238,7 +238,7 @@ Disabled .\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;Foundation_EXPORTS;POCO_STATIC;PCRE_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;Foundation_EXPORTS;POCO_STATIC;PCRE_STATIC;%(PreprocessorDefinitions) true true EnableFastChecks @@ -269,7 +269,7 @@ Speed true .\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;Foundation_EXPORTS;POCO_STATIC;PCRE_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;Foundation_EXPORTS;POCO_STATIC;PCRE_STATIC;%(PreprocessorDefinitions) false false false @@ -1025,6 +1025,8 @@ + + @@ -1034,6 +1036,7 @@ + diff --git a/Foundation/Foundation_x64_vs100.vcxproj.filters b/Foundation/Foundation_x64_vs100.vcxproj.filters index 94b5ee37e..835260466 100644 --- a/Foundation/Foundation_x64_vs100.vcxproj.filters +++ b/Foundation/Foundation_x64_vs100.vcxproj.filters @@ -1013,6 +1013,12 @@ Core\Header Files + + Core\Header Files + + + Core\Header Files + Core\Header Files @@ -1841,6 +1847,9 @@ Text\Header Files + + Core\Header Files + diff --git a/Foundation/Foundation_x64_vs110.vcxproj b/Foundation/Foundation_x64_vs110.vcxproj index 13a842e3a..a4b6d8638 100644 --- a/Foundation/Foundation_x64_vs110.vcxproj +++ b/Foundation/Foundation_x64_vs110.vcxproj @@ -1031,6 +1031,8 @@ + + @@ -1040,6 +1042,7 @@ + diff --git a/Foundation/Foundation_x64_vs110.vcxproj.filters b/Foundation/Foundation_x64_vs110.vcxproj.filters index 94b5ee37e..26e78a271 100644 --- a/Foundation/Foundation_x64_vs110.vcxproj.filters +++ b/Foundation/Foundation_x64_vs110.vcxproj.filters @@ -1013,6 +1013,12 @@ Core\Header Files + + Core\Header Files + + + Core\Header Files + Core\Header Files @@ -1037,6 +1043,9 @@ Core\Header Files + + Core\Header Files + Core\Header Files diff --git a/Foundation/Foundation_x64_vs90.vcproj b/Foundation/Foundation_x64_vs90.vcproj index 3ee699ca6..05fb27781 100644 --- a/Foundation/Foundation_x64_vs90.vcproj +++ b/Foundation/Foundation_x64_vs90.vcproj @@ -1198,6 +1198,14 @@ RelativePath=".\include\Poco\NumberParser.h" > + + + + @@ -1234,6 +1242,10 @@ RelativePath=".\include\Poco\SingletonHolder.h" > + + diff --git a/Foundation/include/Poco/Any.h b/Foundation/include/Poco/Any.h index 34cb595a7..eb8c14555 100644 --- a/Foundation/include/Poco/Any.h +++ b/Foundation/include/Poco/Any.h @@ -5,7 +5,7 @@ // // Library: Foundation // Package: Core -// Module: Any +// Module: Any // // Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. // Extracted from Boost 1.33.1 lib and adapted for poco: Peter Schojer/AppliedInformatics 2006-02-02 @@ -52,17 +52,198 @@ class Any /// /// Code taken from the Boost 1.33.1 library. Original copyright by Kevlin Henney. Modified for Poco /// by Applied Informatics. + /// + /// Modified for small object optimization support (optionally supported through conditional compilation) + /// by Alex Fabijanic. { + +#ifndef POCO_NO_SOO + public: - Any(): - _content(0) + + Any() + /// Creates an empty any type. + { + } + + template + Any(const ValueType & value) + /// Creates an any which stores the init parameter inside. + /// + /// Example: + /// Any a(13); + /// Any a(string("12345")); + { + construct(value); + } + + Any(const Any& other) + /// Copy constructor, works with both empty and initialized Any values. + { + construct(other); + } + + ~Any() + { + if(!empty()) + { + if(flag()) + content()->~Placeholder(); + else + delete content(); + } + } + + template + Any & operator=(const ValueType& value) + /// Assignment operator for all types != Any. + /// + /// Example: + /// Any a = 13; + /// Any a = string("12345"); + { + this->~Any(); + construct(value); + return *this; + } + + Any& operator = (Any value) + /// Assignment operator for Any. + { + this->~Any(); + construct(value); + return *this; + } + + bool empty() const + /// Returns true if the Any is empty. + { + //return !(flags() & ASSIGNED); + return _placeholder.pHolder == 0; + } + + const std::type_info & type() const + /// Returns the type information of the stored content. + /// If the Any is empty typeid(void) is returned. + /// It is recommended to always query an Any for its type info before + /// trying to extract data via an AnyCast/RefAnyCast. + { + return empty() ? typeid(void) : content()->type(); + } + +private: + + class Placeholder + { + public: + + virtual ~Placeholder() + { + } + + virtual const std::type_info & type() const = 0; + virtual Placeholder * clone(Placeholder* pMem = 0) const = 0; + }; + + template + class Holder : public Placeholder + { + public: + Holder(const ValueType & value) : _held(value) + { + } + + virtual const std::type_info & type() const + { + return typeid(ValueType); + } + + virtual Placeholder * clone(Placeholder* pMem = 0) const + { + return pMem && (sizeof(_held) <= POCO_SMALL_OBJECT_SIZE) ? + new (pMem) Holder(_held) : + new Holder(_held); + } + + ValueType _held; + + private: + Holder & operator = (const Holder &); + }; + + Placeholder* content() const + { + if (empty()) return 0; + + if(flag()) + return (Placeholder *) &(_placeholder.holder); + else + return _placeholder.pHolder; + } + + template + void construct(const ValueType & value) + { + if (sizeof(Holder) <= POCO_SMALL_OBJECT_SIZE) + { + new (_placeholder.holder) Holder(value); + flag() = 1; + } + else + { + _placeholder.pHolder = new Holder(value); + flag() = 0; + } + } + + void construct(const Any & other) + { + if(other.flag()) + { + other.content()->clone((Placeholder*) &_placeholder.holder); + flag() = 1; + return; + } + else if(!(other.empty())) + _placeholder.pHolder = other._placeholder.pHolder->clone(); + + flag() = 0; + } + + union PH + /// Placeholder union. If Holder fits into POCO_SMALL_OBJECT_SIZE + /// bytes of storage, it will be placement-new-allocated into the local buffer + /// (i.e. there will be no heap-allocation. The local buffer size is one byte + /// larger - [POCO_SMALL_OBJECT_SIZE + 1], additional byte value indicating + /// where the object was allocated (0 => heap, 1 => local). + { + PH () + { + std::memset(holder, 0, sizeof(PH)); + } + + Placeholder* pHolder; + mutable unsigned char holder[POCO_SMALL_OBJECT_SIZE + 1]; + } _placeholder; + + unsigned char& flag() const + { + return _placeholder.holder[POCO_SMALL_OBJECT_SIZE]; + } + + +#else // if POCO_NO_SOO + + +public: + Any(): _pHolder(0) /// Creates an empty any type. { } template Any(const ValueType& value): - _content(new Holder(value)) + _pHolder(new Holder(value)) /// Creates an any which stores the init parameter inside. /// /// Example: @@ -72,20 +253,20 @@ public: } Any(const Any& other): - _content(other._content ? other._content->clone() : 0) - /// Copy constructor, works with empty Anys and initialized Any values. + _pHolder(other._pHolder ? other._pHolder->clone() : 0) + /// Copy constructor, works with both empty and initialized Any values. { } ~Any() { - delete _content; + delete _pHolder; } Any& swap(Any& rhs) /// Swaps the content of the two Anys. { - std::swap(_content, rhs._content); + std::swap(_pHolder, rhs._pHolder); return *this; } @@ -94,8 +275,8 @@ public: /// Assignment operator for all types != Any. /// /// Example: - /// Any a = 13; - /// Any a = string("12345"); + /// Any a = 13; + /// Any a = string("12345"); { Any(rhs).swap(*this); return *this; @@ -109,18 +290,18 @@ public: } bool empty() const - /// returns true if the Any is empty + /// Returns true if the Any is empty. { - return !_content; + return !_pHolder; } const std::type_info& type() const /// Returns the type information of the stored content. /// If the Any is empty typeid(void) is returned. - /// It is suggested to always query an Any for its type info before trying to extract - /// data via an AnyCast/RefAnyCast. + /// It is recommended to always query an Any for its type info before + /// trying to extract data via an AnyCast/RefAnyCast. { - return _content ? _content->type() : typeid(void); + return _pHolder ? _pHolder->type() : typeid(void); } private: @@ -155,16 +336,27 @@ private: } ValueType _held; + + private: + Holder & operator=(const Holder &); }; + Placeholder* content() const + { + return _pHolder; + } + private: + Placeholder* _pHolder; + +#endif // POCO_NO_SOO + template friend ValueType* AnyCast(Any*); template friend ValueType* UnsafeAnyCast(Any*); - Placeholder* _content; }; @@ -178,7 +370,7 @@ ValueType* AnyCast(Any* operand) /// Will return NULL if the cast fails, i.e. types don't match. { return operand && operand->type() == typeid(ValueType) - ? &static_cast*>(operand->_content)->_held + ? &static_cast*>(operand->content())->_held : 0; } @@ -264,7 +456,7 @@ ValueType* UnsafeAnyCast(Any* operand) /// use typeid() comparison, e.g., when our types may travel across /// different shared libraries. { - return &static_cast*>(operand->_content)->_held; + return &static_cast*>(operand->_pHolder)->_held; } diff --git a/Foundation/include/Poco/Config.h b/Foundation/include/Poco/Config.h index 0079ee0c3..fa69a1952 100644 --- a/Foundation/include/Poco/Config.h +++ b/Foundation/include/Poco/Config.h @@ -86,6 +86,12 @@ // #define POCO_THREAD_PRIORITY_MAX 31 +// Define to disable small object optimization. +// If not defined, Any and Dynamic::Var (and similar +// optimization candidates) will be auto-allocated on the +// stack in cases when value holder fits into . +// #define POCO_NO_SOO + // Following are options to remove certain features // to reduce library/executable size for smaller // embedded platforms. By enabling these options, diff --git a/Foundation/include/Poco/SmallObjectAllocator.h b/Foundation/include/Poco/SmallObjectAllocator.h new file mode 100644 index 000000000..be7cc8b19 --- /dev/null +++ b/Foundation/include/Poco/SmallObjectAllocator.h @@ -0,0 +1,251 @@ +// +// SmallObjectAllocator.h +// +// $Id: //poco/1.4/Foundation/include/Poco/SmallObjectAllocator.h#1 $ +// +// Library: Foundation +// Package: Core +// Module: SmallObjectAllocator +// +// Definition of the SmallObjectAllocator template. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// + + +#ifndef Foundation_SmallObjectAllocator_INCLUDED +#define Foundation_SmallObjectAllocator_INCLUDED + + +#include "Poco/Foundation.h" +#include "Poco/Types.h" + + +namespace Poco { + + +template +class SmallObjectAllocator + /// SmallObjectAllocator template is a lightweight wrapper implementing + /// small object allocation optimization idiom. Class is statically + /// parameterized on type created and the size threshold, which defaults + /// to the created object size; it follows that the default behavior is + /// use of automatically allocated memory (i.e. the value wrapped is + /// stored in the pre-allocated buffer). To enforce heap allocation, + /// specify S parameter to a value smaller than the size of the type + /// being instantiated. + /// + /// The SmallObjectAllocator trade-off is the runtime check for memory + /// location where the value resides. The runtime check occurs at + /// construction/destruction as well as every value access. Value + /// access check can be alleviated by caching the value reference. + /// + /// Usage example: + /// + /// SmallObjectAllocator s; // on the stack + /// SmallObjectAllocator h; // force heap alloc + /// int& i = s.get(); // no runtime performance penalty after this point + /// i = 5; + /// +{ +public: + SmallObjectAllocator() + { + if (isOnHeap()) _memory.ptr = new T(); + else new (_memory.buf) T; + } + + SmallObjectAllocator(const T& val) + { + if (isOnHeap()) _memory.ptr = new T(val); + else new (_memory.buf) T(val); + } + + SmallObjectAllocator(const SmallObjectAllocator& other) + { + if (this != &other) + { + if (isOnHeap()) + _memory.ptr = new T(*other._memory.ptr); + else + new (_memory.buf) T(*reinterpret_cast(other._memory.buf)); + } + } + + ~SmallObjectAllocator() + { + if (isOnHeap()) delete _memory.ptr; + else reinterpret_cast(_memory.buf)->~T(); + } + + SmallObjectAllocator& operator =(const SmallObjectAllocator& other) + { + if (this != &other) + { + if (isOnHeap()) + _memory.ptr = new T(*other._memory.ptr); + else + new (_memory.buf) T(*reinterpret_cast(other._memory.buf)); + } + + return *this; + } + + T& get() + { + if (isOnHeap()) + return *_memory.ptr; + else + return reinterpret_cast(*(_memory.buf)); + } + + const T& get() const + { + if (isOnHeap()) + return *_memory.ptr; + else + return reinterpret_cast(*_memory.buf); + } + + bool isOnHeap() const + { + return sizeof(T) > S; + } + +private: + union + { + unsigned char buf[S]; + T* ptr; + } _memory; +}; + + +template <> +class SmallObjectAllocator + /// SmallObjectAllocator char* specialization. + /// + /// The treshold between auto and heap allocation + /// is controlled through POCO_SMALL_OBJECT_SIZE compile + /// time constant, which on 32 or 64 systems defaults + /// to 31 or 63 bytes respectively. This specialization + /// adds an extra byte to indicate the allocation strategy. + /// + /// To summarize, e.g. POCO_SMALL_OBJECT_SIZE value of 7 will + /// take up at least 8 bytes of storage (for auto allocation) + /// with 6 bytes as the effective string length: + /// + /// +---+---+---+---+---+---+---+---+ + /// | c | c | c | c | c | c | 0 | f | + /// +---+---+---+---+---+---+---+---+ + /// + /// Legend: + /// c - character + /// 0 - terminating zero + /// f - allocation flag + /// +{ +public: + static const std::size_t Size = POCO_SMALL_OBJECT_SIZE; + + SmallObjectAllocator(std::size_t sz) + { + _memory.buf[Size] = (sz > Size) ? 1 : 0; + if (_memory.buf[Size]) _memory.ptr = new char[sz + 1]; + } + + SmallObjectAllocator(const char* pCh, std::size_t sz) + { + allocateAndAssign(pCh, sz); + } + + SmallObjectAllocator(const char* pCh) + { + allocateAndAssign(pCh, strlen(pCh)); + } + + ~SmallObjectAllocator() + { + if (_memory.buf[Size]) delete _memory.ptr; + } + + SmallObjectAllocator & operator = (const char* pCh) + { + allocateAndAssign(pCh, strlen(pCh)); + return *this; + } + + char* get() + { + if (_memory.buf[Size]) return _memory.ptr; + else return _memory.buf; + } + + const char* get() const + { + if (_memory.buf[Size]) return _memory.ptr; + else return _memory.buf; + } + + bool isOnHeap() const + { + return _memory.buf[Size] != 0; + } + +private: + SmallObjectAllocator(); + + void allocateAndAssign(const char* pCh, std::size_t sz) + { + _memory.buf[Size] = (sz > Size) ? 1 : 0; + if (_memory.buf[Size]) + { + _memory.ptr = new char[sz + 1]; + _memory.ptr[sz] = '\0'; + std::memcpy(_memory.ptr, pCh, sz); + } + else + { + _memory.buf[sz] = '\0'; + std::memcpy(_memory.buf, pCh, sz); + } + } + + union + { + char buf[Size + 1]; + char* ptr; + } _memory; +}; + + +typedef SmallObjectAllocator SmallStringAllocator; + + +} // namespace Poco + + +#endif // Foundation_SmallObjectAllocator_INCLUDED diff --git a/Foundation/include/Poco/Types.h b/Foundation/include/Poco/Types.h index 6f1c41a27..6c87ef118 100644 --- a/Foundation/include/Poco/Types.h +++ b/Foundation/include/Poco/Types.h @@ -220,6 +220,17 @@ namespace Poco { #endif +// Small object size in bytes. Where applicable (e.g. +// SmallObjectAllocator specialization of , Any, etc) +// objects longer than this value will be alocated on the heap. +// See Poco/SmallObjectAllocator.h for details. +#if (POCO_PTR_IS_64_BIT == 1) + #define POCO_SMALL_OBJECT_SIZE 63 +#else + #define POCO_SMALL_OBJECT_SIZE 31 +#endif + + } // namespace Poco diff --git a/Foundation/src/FIFOBufferStream.cpp b/Foundation/src/FIFOBufferStream.cpp index 212c2b22c..ccf42fa33 100644 --- a/Foundation/src/FIFOBufferStream.cpp +++ b/Foundation/src/FIFOBufferStream.cpp @@ -95,14 +95,14 @@ FIFOBufferStreamBuf::~FIFOBufferStreamBuf() int FIFOBufferStreamBuf::readFromDevice(char* buffer, std::streamsize length) { poco_assert (length > 0); - return _fifoBuffer.read(buffer, static_cast(length)); + return static_cast(_fifoBuffer.read(buffer, static_cast(length))); } int FIFOBufferStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { poco_assert (length > 0); - return _fifoBuffer.write(buffer, static_cast(length)); + return static_cast(_fifoBuffer.write(buffer, static_cast(length))); } diff --git a/Foundation/testsuite/TestApp_x64_vs100.vcxproj b/Foundation/testsuite/TestApp_x64_vs100.vcxproj index 84d3cd7d8..a777c7291 100644 --- a/Foundation/testsuite/TestApp_x64_vs100.vcxproj +++ b/Foundation/testsuite/TestApp_x64_vs100.vcxproj @@ -122,7 +122,7 @@ Disabled %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -152,7 +152,7 @@ Speed true %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions) true MultiThreadedDLL false @@ -185,7 +185,7 @@ Speed true %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions) true MultiThreadedDLL false @@ -214,7 +214,7 @@ Disabled %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -240,7 +240,7 @@ Disabled %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -270,7 +270,7 @@ Speed true %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions) true MultiThreaded false diff --git a/Foundation/testsuite/TestLibrary_x64_vs100.vcxproj b/Foundation/testsuite/TestLibrary_x64_vs100.vcxproj index 9c407dfb1..8ab0988a6 100644 --- a/Foundation/testsuite/TestLibrary_x64_vs100.vcxproj +++ b/Foundation/testsuite/TestLibrary_x64_vs100.vcxproj @@ -51,7 +51,7 @@ Disabled ..\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true EnableFastChecks @@ -85,7 +85,7 @@ Speed true ..\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true MultiThreadedDLL false diff --git a/Foundation/testsuite/TestSuite_x64_vs100.vcxproj b/Foundation/testsuite/TestSuite_x64_vs100.vcxproj index ed762843e..baae24b0c 100644 --- a/Foundation/testsuite/TestSuite_x64_vs100.vcxproj +++ b/Foundation/testsuite/TestSuite_x64_vs100.vcxproj @@ -115,7 +115,7 @@ Disabled ..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;WINVER=0x0600;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;WINVER=0x0600;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -146,7 +146,7 @@ Speed true ..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;WINVER=0x0600;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;WINVER=0x0600;%(PreprocessorDefinitions) true MultiThreadedDLL false @@ -180,7 +180,7 @@ Speed true ..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) true Default MultiThreadedDLL @@ -211,7 +211,7 @@ Disabled ..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -238,7 +238,7 @@ Disabled ..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;_DEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -270,7 +270,7 @@ Speed true ..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) + WIN32;_WIN64;NDEBUG;_WINDOWS;WINVER=0x0600;POCO_STATIC;%(PreprocessorDefinitions) true false Default diff --git a/Foundation/testsuite/src/AnyTest.cpp b/Foundation/testsuite/src/AnyTest.cpp index 82dbe8f9d..3fee242d9 100644 --- a/Foundation/testsuite/src/AnyTest.cpp +++ b/Foundation/testsuite/src/AnyTest.cpp @@ -72,6 +72,9 @@ AnyTest::~AnyTest() void AnyTest::testInt() { + Any e; + assert (e.empty()); + Any a = 13; assert (a.type() == typeid(int)); int* i = AnyCast(&a); diff --git a/Foundation/testsuite/src/CoreTest.cpp b/Foundation/testsuite/src/CoreTest.cpp index 0a2bf5e9e..78187e8e9 100644 --- a/Foundation/testsuite/src/CoreTest.cpp +++ b/Foundation/testsuite/src/CoreTest.cpp @@ -45,6 +45,7 @@ #include "Poco/Ascii.h" #include "Poco/BasicEvent.h" #include "Poco/Delegate.h" +#include "Poco/SmallObjectAllocator.h" #include "Poco/Exception.h" #include #include @@ -64,6 +65,7 @@ using Poco::AtomicCounter; using Poco::Nullable; using Poco::Ascii; using Poco::BasicEvent; +using Poco::SmallObjectAllocator; using Poco::delegate; using Poco::NullType; using Poco::InvalidAccessException; @@ -96,6 +98,37 @@ namespace } +class Small +{ +}; + + +struct Parent +{ + Parent() { i = -1; } + virtual ~Parent() { i= -2; } + + static int i; +}; + + +int Parent::i = 0; + + +struct Medium : public Parent +{ + +}; + + +struct Large +{ + Large() : i(1), j(2), k(3), l(4) { } + long i,j,k; + const long l; +}; + + // // The bugcheck test is normally disabled, as it // causes a break into the debugger. @@ -1031,6 +1064,137 @@ void CoreTest::testAscii() } +void CoreTest::testSmallObjectAllocator() +{ + { + SmallObjectAllocator soa1; + assert (!soa1.isOnHeap()); + int& i = soa1.get(); + i = 42; + int j = i; + assert (j == 42); + int* pi = &i; + assert (*pi == 42); + *pi = 24; + assert (i == 24); + SmallObjectAllocator soa2(soa1); + assert (soa1.get() == soa2.get()); + assert (soa2.get() == 24); + + SmallObjectAllocator soa3; + soa3 = soa2; + assert (soa3.get() == soa2.get()); + assert (soa3.get() == 24); + } + { + // force heap alloc + SmallObjectAllocator soa1; + assert (soa1.isOnHeap()); + int& i = soa1.get(); + i = 42; + int j = i; + assert (j == 42); + int* pi = &i; + assert (*pi == 42); + *pi = 24; + assert (i == 24); + SmallObjectAllocator soa2(soa1); + assert (soa1.get() == soa2.get()); + assert (soa2.get() == 24); + + SmallObjectAllocator soa3; + soa3 = soa2; + assert (soa3.get() == soa2.get()); + assert (soa3.get() == 24); + } + + SmallObjectAllocator soa2; + assert (!soa2.isOnHeap()); + + { + assert (Parent::i == 0); + SmallObjectAllocator soa3; + assert (!soa3.isOnHeap()); + assert (Parent::i == -1); + } + assert (Parent::i == -2); + + { + typedef SmallObjectAllocator LargeType; + LargeType soa4; + assert (soa4.isOnHeap()); + Large large = soa4.get(); + assert (large.i == 1); + assert (large.j == 2); + assert (large.k == 3); + + const LargeType soa5; + assert (soa5.get().l == 4); + } + + Parent::i = 0; // only to make sure subsequent runs don't fail + + SmallObjectAllocator soa6(2); + assert (!soa6.isOnHeap()); + char* pC2 = soa6.get(); + pC2[0] = 'x'; + pC2[1] = '\0'; + std::string str2(pC2); + assert (str2 == "x"); + + std::size_t sz = POCO_SMALL_OBJECT_SIZE + 1; + Poco::SmallStringAllocator soa7(sz); + assert (soa7.isOnHeap()); + char* pC = soa7.get(); + char c = '0'; + int i = 0; + + // test this only for default values + if (POCO_SMALL_OBJECT_SIZE == 15) + { + for (i = 0; i < sz - 1; ++i) + pC[i] = c++; + pC[i] = '\0'; + std::string str(pC); + assert (str == "0123456789:;<=>"); + + Poco::SmallStringAllocator soa7("0123456789:;<=>"); + assert (str == soa7.get()); + + soa7 = ""; + assert (soa7.get()[0] == '\0'); + soa7 = "0123456789:;<=>"; + assert (str == soa7.get()); + } + else if (POCO_SMALL_OBJECT_SIZE == 7) + { + for (i = 0; i < sz - 1; ++i) + pC[i] = c++; + pC[i] = '\0'; + std::string str(pC); + assert (str == "0123456"); + + Poco::SmallStringAllocator soa7("0123456"); + assert (str == soa7.get()); + + soa7 = ""; + assert (soa7.get()[0] == '\0'); + soa7 = "0123456"; + assert (str == soa7.get()); + } + + std::string str("0123456789"); + Poco::SmallObjectAllocator soa8(str); + assert (!soa8.isOnHeap()); + assert(soa8.get() == str); + + Poco::SmallObjectAllocator soa9; + assert (soa9.isOnHeap()); + soa9 = str; + assert(soa9.get() == str); +} + + void CoreTest::onReadable(bool& b) { if (b) ++_notToReadable; @@ -1074,6 +1238,7 @@ CppUnit::Test* CoreTest::suite() CppUnit_addTest(pSuite, CoreTest, testAtomicCounter); CppUnit_addTest(pSuite, CoreTest, testNullable); CppUnit_addTest(pSuite, CoreTest, testAscii); + CppUnit_addTest(pSuite, CoreTest, testSmallObjectAllocator); return pSuite; } diff --git a/Foundation/testsuite/src/CoreTest.h b/Foundation/testsuite/src/CoreTest.h index a521fce91..4d4eed110 100644 --- a/Foundation/testsuite/src/CoreTest.h +++ b/Foundation/testsuite/src/CoreTest.h @@ -58,6 +58,7 @@ public: void testAtomicCounter(); void testNullable(); void testAscii(); + void testSmallObjectAllocator(); void setUp(); void tearDown(); diff --git a/Net/Net_CE_vs90.vcproj b/Net/Net_CE_vs90.vcproj index e052a621f..47a58b2ec 100644 --- a/Net/Net_CE_vs90.vcproj +++ b/Net/Net_CE_vs90.vcproj @@ -438,6 +438,8 @@ RelativePath=".\include\Poco\Net\HostEntry.h"/> + + + @@ -375,6 +376,7 @@ + diff --git a/Net/Net_vs110.vcxproj.filters b/Net/Net_vs110.vcxproj.filters index 2a92c74b7..7bca18a6b 100644 --- a/Net/Net_vs110.vcxproj.filters +++ b/Net/Net_vs110.vcxproj.filters @@ -138,6 +138,9 @@ NetCore\Header Files + + NetCore\Header Files + NetCore\Header Files @@ -431,6 +434,9 @@ NetCore\Source Files + + NetCore\Source Files + NetCore\Source Files diff --git a/Net/Net_vs71.vcproj b/Net/Net_vs71.vcproj index bcd35cd99..440c65da4 100644 --- a/Net/Net_vs71.vcproj +++ b/Net/Net_vs71.vcproj @@ -370,6 +370,8 @@ RelativePath=".\include\Poco\Net\HostEntry.h"/> + + + + + + + @@ -32,76 +32,76 @@ Net Win32Proj - - + + StaticLibrary MultiByte - + StaticLibrary MultiByte - + StaticLibrary MultiByte - + StaticLibrary MultiByte - + DynamicLibrary MultiByte - + DynamicLibrary MultiByte - - - - + + + + - - + + - - + + - - + + - - + + - - + + - + <_ProjectFileVersion>10.0.40219.1 - ..\bin64\ - obj64\$(Configuration)\ - true - ..\bin64\ - obj64\$(Configuration)\ - false - ..\lib64\ - obj64\$(Configuration)\ - ..\lib64\ - obj64\$(Configuration)\ - ..\lib64\ - obj64\$(Configuration)\ - ..\lib64\ - obj64\$(Configuration)\ - PocoNet64d - PocoNetmdd - PocoNetmtd - PocoNet64 - PocoNetmd - PocoNetmt + ..\bin64\ + obj64\$(Configuration)\ + true + ..\bin64\ + obj64\$(Configuration)\ + false + ..\lib64\ + obj64\$(Configuration)\ + ..\lib64\ + obj64\$(Configuration)\ + ..\lib64\ + obj64\$(Configuration)\ + ..\lib64\ + obj64\$(Configuration)\ + PocoNet64d + PocoNetmdd + PocoNetmtd + PocoNet64 + PocoNetmd + PocoNetmt - + Disabled .\include;..\Foundation\include;%(AdditionalIncludeDirectories) @@ -114,7 +114,7 @@ true true true - + Level3 ProgramDatabase Default @@ -132,7 +132,7 @@ MachineX64 - + Disabled OnlyExplicitInline @@ -147,9 +147,9 @@ true true true - + Level3 - + Default %(DisableSpecificWarnings) @@ -166,7 +166,7 @@ MachineX64 - + Disabled .\include;..\Foundation\include;%(AdditionalIncludeDirectories) @@ -179,7 +179,7 @@ true true true - + ..\lib64\PocoNetmtd.pdb Level3 ProgramDatabase @@ -190,7 +190,7 @@ ..\lib64\PocoNetmtd.lib - + Disabled OnlyExplicitInline @@ -205,9 +205,9 @@ true true true - + Level3 - + Default %(DisableSpecificWarnings) @@ -215,7 +215,7 @@ ..\lib64\PocoNetmt.lib - + Disabled .\include;..\Foundation\include;%(AdditionalIncludeDirectories) @@ -228,7 +228,7 @@ true true true - + ..\lib64\PocoNetmdd.pdb Level3 ProgramDatabase @@ -239,7 +239,7 @@ ..\lib64\PocoNetmdd.lib - + Disabled OnlyExplicitInline @@ -254,9 +254,9 @@ true true true - + Level3 - + Default %(DisableSpecificWarnings) @@ -265,207 +265,209 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - true - true - true - true - true - true + true + true + true + true + true + true - - - + + + \ No newline at end of file diff --git a/Net/Net_x64_vs100.vcxproj.filters b/Net/Net_x64_vs100.vcxproj.filters index cc5d83829..392d423af 100644 --- a/Net/Net_x64_vs100.vcxproj.filters +++ b/Net/Net_x64_vs100.vcxproj.filters @@ -420,6 +420,9 @@ WebSocket\Header Files + + NetCore\Header Files + @@ -695,6 +698,9 @@ WebSocket\Source Files + + NetCore\Source Files + diff --git a/Net/Net_x64_vs110.vcxproj b/Net/Net_x64_vs110.vcxproj index 9d16c8861..810f6dfc9 100644 --- a/Net/Net_x64_vs110.vcxproj +++ b/Net/Net_x64_vs110.vcxproj @@ -274,6 +274,7 @@ + @@ -373,6 +374,7 @@ + diff --git a/Net/Net_x64_vs110.vcxproj.filters b/Net/Net_x64_vs110.vcxproj.filters index 5ed32e62e..18dd8f2dd 100644 --- a/Net/Net_x64_vs110.vcxproj.filters +++ b/Net/Net_x64_vs110.vcxproj.filters @@ -138,6 +138,9 @@ NetCore\Header Files + + NetCore\Header Files + NetCore\Header Files @@ -431,6 +434,9 @@ NetCore\Source Files + + NetCore\Source Files + NetCore\Source Files diff --git a/Net/Net_x64_vs90.vcproj b/Net/Net_x64_vs90.vcproj index 153ea2f46..d087f6a66 100644 --- a/Net/Net_x64_vs90.vcproj +++ b/Net/Net_x64_vs90.vcproj @@ -395,6 +395,8 @@ RelativePath=".\include\Poco\Net\HostEntry.h"/> + + sendBytes(&fifoBuf.buffer()[0], fifoBuf.used()); + int ret = impl()->sendBytes(&fifoBuf.buffer()[0], (int) fifoBuf.used()); if (ret > 0) fifoBuf.drain(ret); return ret; } @@ -150,7 +150,7 @@ int StreamSocket::receiveBytes(void* buffer, int length, int flags) int StreamSocket::receiveBytes(FIFOBuffer& fifoBuf) { - int ret = impl()->receiveBytes(fifoBuf.next(), fifoBuf.available()); + int ret = impl()->receiveBytes(fifoBuf.next(), (int) fifoBuf.available()); if (ret > 0) fifoBuf.advance(ret); return ret; } diff --git a/Net/testsuite/src/WebSocketTest.cpp b/Net/testsuite/src/WebSocketTest.cpp index 568dbfa5b..2daf0ce26 100644 --- a/Net/testsuite/src/WebSocketTest.cpp +++ b/Net/testsuite/src/WebSocketTest.cpp @@ -129,7 +129,7 @@ void WebSocketTest::testWebSocket() WebSocket ws(cs, request, response); std::string payload("x"); - ws.sendFrame(payload.data(), payload.size()); + ws.sendFrame(payload.data(), (int) payload.size()); char buffer[1024]; int flags; int n = ws.receiveFrame(buffer, sizeof(buffer), flags); @@ -140,7 +140,7 @@ void WebSocketTest::testWebSocket() for (int i = 2; i < 20; i++) { payload.assign(i, 'x'); - ws.sendFrame(payload.data(), payload.size()); + ws.sendFrame(payload.data(), (int) payload.size()); n = ws.receiveFrame(buffer, sizeof(buffer), flags); assert (n == payload.size()); assert (payload.compare(0, payload.size(), buffer, 0, n) == 0); @@ -150,7 +150,7 @@ void WebSocketTest::testWebSocket() for (int i = 125; i < 129; i++) { payload.assign(i, 'x'); - ws.sendFrame(payload.data(), payload.size()); + ws.sendFrame(payload.data(), (int) payload.size()); n = ws.receiveFrame(buffer, sizeof(buffer), flags); assert (n == payload.size()); assert (payload.compare(0, payload.size(), buffer, 0, n) == 0); @@ -158,14 +158,14 @@ void WebSocketTest::testWebSocket() } payload = "Hello, world!"; - ws.sendFrame(payload.data(), payload.size()); + ws.sendFrame(payload.data(), (int) payload.size()); n = ws.receiveFrame(buffer, sizeof(buffer), flags); assert (n == payload.size()); assert (payload.compare(0, payload.size(), buffer, 0, n) == 0); assert (flags == WebSocket::FRAME_TEXT); payload = "Hello, universe!"; - ws.sendFrame(payload.data(), payload.size(), WebSocket::FRAME_BINARY); + ws.sendFrame(payload.data(), (int) payload.size(), WebSocket::FRAME_BINARY); n = ws.receiveFrame(buffer, sizeof(buffer), flags); assert (n == payload.size()); assert (payload.compare(0, payload.size(), buffer, 0, n) == 0); diff --git a/Util/Util_vs100.vcxproj b/Util/Util_vs100.vcxproj index 5319633ff..094a48e2c 100644 --- a/Util/Util_vs100.vcxproj +++ b/Util/Util_vs100.vcxproj @@ -1,4 +1,4 @@ - + @@ -32,76 +32,76 @@ Util Win32Proj - - + + StaticLibrary MultiByte - + StaticLibrary MultiByte - + StaticLibrary MultiByte - + StaticLibrary MultiByte - + DynamicLibrary MultiByte - + DynamicLibrary MultiByte - - - - + + + + - - + + - - + + - - + + - - + + - - + + - + <_ProjectFileVersion>10.0.40219.1 - ..\bin\ - obj\$(Configuration)\ - true - ..\bin\ - obj\$(Configuration)\ - false - ..\lib\ - obj\$(Configuration)\ - ..\lib\ - obj\$(Configuration)\ - ..\lib\ - obj\$(Configuration)\ - ..\lib\ - obj\$(Configuration)\ - PocoUtild - PocoUtilmdd - PocoUtilmtd - PocoUtil - PocoUtilmd - PocoUtilmt + ..\bin\ + obj\$(Configuration)\ + true + ..\bin\ + obj\$(Configuration)\ + false + ..\lib\ + obj\$(Configuration)\ + ..\lib\ + obj\$(Configuration)\ + ..\lib\ + obj\$(Configuration)\ + ..\lib\ + obj\$(Configuration)\ + PocoUtild + PocoUtilmdd + PocoUtilmtd + PocoUtil + PocoUtilmd + PocoUtilmt - + Disabled .\include;..\Foundation\include;..\XML\include;..\JSON\include;%(AdditionalIncludeDirectories) @@ -114,7 +114,7 @@ true true true - + Level3 EditAndContinue Default @@ -132,7 +132,7 @@ MachineX86 - + Disabled OnlyExplicitInline @@ -147,9 +147,9 @@ true true true - + Level3 - + Default %(DisableSpecificWarnings) @@ -166,7 +166,7 @@ MachineX86 - + Disabled .\include;..\Foundation\include;..\XML\include;..\JSON\include;%(AdditionalIncludeDirectories) @@ -179,7 +179,7 @@ true true true - + ..\lib\PocoUtilmtd.pdb Level3 EditAndContinue @@ -190,7 +190,7 @@ ..\lib\PocoUtilmtd.lib - + Disabled OnlyExplicitInline @@ -205,9 +205,9 @@ true true true - + Level3 - + Default %(DisableSpecificWarnings) @@ -215,7 +215,7 @@ ..\lib\PocoUtilmt.lib - + Disabled .\include;..\Foundation\include;..\XML\include;..\JSON\include;%(AdditionalIncludeDirectories) @@ -228,7 +228,7 @@ true true true - + ..\lib\PocoUtilmdd.pdb Level3 EditAndContinue @@ -239,7 +239,7 @@ ..\lib\PocoUtilmdd.lib - + Disabled OnlyExplicitInline @@ -254,10 +254,10 @@ true true true - + ..\lib\PocoUtilmd.pdb Level3 - + Default %(DisableSpecificWarnings) @@ -267,79 +267,80 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - true - true - true - true + true + true + true + true - - - + + + \ No newline at end of file diff --git a/Util/Util_vs100.vcxproj.filters b/Util/Util_vs100.vcxproj.filters index f6724f69b..7d6736c6c 100644 --- a/Util/Util_vs100.vcxproj.filters +++ b/Util/Util_vs100.vcxproj.filters @@ -153,6 +153,9 @@ Timer\Header Files + + Util\Header Files +