$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: john.groups_at_[hidden]
Date: 2007-11-03 17:43:36
Author: jtorjo
Date: 2007-11-03 17:43:34 EDT (Sat, 03 Nov 2007)
New Revision: 40729
URL: http://svn.boost.org/trac/boost/changeset/40729
Log:
[logging]
v0.10.6, 3 nov 2007
- added TSS tests 
  - test test_tss SUCCESSFUL on win32
  - test test_simple_tss SUCCESSFUL on win32
Added:
   sandbox/logging/lib/logging/tests/test_simple_tss/
   sandbox/logging/lib/logging/tests/test_simple_tss/test_simple_tss.cpp   (contents, props changed)
   sandbox/logging/lib/logging/tests/test_simple_tss/test_simple_tss.sln   (contents, props changed)
   sandbox/logging/lib/logging/tests/test_simple_tss/test_simple_tss.vcproj   (contents, props changed)
Properties modified: 
   sandbox/logging/lib/logging/tests/test_ts_resouce_with_cache/   (props changed)
Text files modified: 
   sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp            |     5 +++--                                   
   sandbox/logging/boost/logging/detail/tss/tss.hpp                      |     9 ++++++---                               
   sandbox/logging/lib/logging/tests/test_tss/count.h                    |    15 ++++++++++++++-                         
   sandbox/logging/lib/logging/tests/test_tss/test_tss.cpp               |    13 +++++++++++++                           
   sandbox/logging/lib/logging/tests/test_tss/test_tss_objects.cpp       |    17 +++++++++++++++--                       
   sandbox/logging/lib/logging/tests/test_tss/test_tss_on_end_delete.cpp |    12 ++++++++++++                            
   6 files changed, 63 insertions(+), 8 deletions(-)
Modified: sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp	(original)
+++ sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp	2007-11-03 17:43:34 EDT (Sat, 03 Nov 2007)
@@ -1,9 +1,10 @@
 /** 
 @page page_changelog Changelog
 
-v0.10.5, 3 nov 2007
+v0.10.6, 3 nov 2007
 - added TSS tests 
-  - test test_tss FAILS - to check!
+  - test test_tss SUCCESSFUL on win32
+  - test test_simple_tss SUCCESSFUL on win32
   - test test_ts_resource_with_cache - not tested
 - added TSS - however, not tested (TSS is off, for now)
 - compiles on VS2005, gcc 3.4.2 , gcc 4.1 and gcc 4.3
Modified: sandbox/logging/boost/logging/detail/tss/tss.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/tss/tss.hpp	(original)
+++ sandbox/logging/boost/logging/detail/tss/tss.hpp	2007-11-03 17:43:34 EDT (Sat, 03 Nov 2007)
@@ -47,15 +47,16 @@
 
 
 template<class type, template<typename> class thread_specific_ptr_type BOOST_LOG_TSS_DEFAULT_CLASS > struct tss_value {
-    tss_value(const type & default_ = type() ) : m_default( default_) {}
+    tss_value(const type & default_ ) : m_default( default_), m_use_default(true) {}
+    tss_value() : m_use_default(false) {}
 
     type * get() const {
         type * result = m_value.get();
         if ( !result) {
 #if defined(BOOST_LOG_TSS_USE_INTERNAL)
-            result = detail::new_object_ensure_delete<type>(m_default);
+            result = m_use_default ? detail::new_object_ensure_delete<type>(m_default) : detail::new_object_ensure_delete<type>();
 #else
-            result = new type(m_default);
+            result = m_use_default ? (new type(m_default)) : (new type);
 #endif
             m_value.reset( result );
         }
@@ -68,6 +69,8 @@
     mutable thread_specific_ptr_type<type> m_value;
     // the default value - to assign each time a new value is created
     type m_default;
+    // if true, use default, otherwise not
+    bool m_use_default;
 };
 
 }}
Added: sandbox/logging/lib/logging/tests/test_simple_tss/test_simple_tss.cpp
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/tests/test_simple_tss/test_simple_tss.cpp	2007-11-03 17:43:34 EDT (Sat, 03 Nov 2007)
@@ -0,0 +1,143 @@
+// test_simple_tss.cpp : Defines the entry point for the console application.
+//
+// Boost Logging library
+//
+// Author: John Torjo, www.torjo.com
+//
+// Copyright (C) 2007 John Torjo (see www.torjo.com for email)
+//
+// Distributed under the Boost Software License, Version 1.0.
+//    (See accompanying file LICENSE_1_0.txt or copy at
+//          http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org for updates, documentation, and revision history.
+// See http://www.torjo.com/log2/ for more details
+
+/* 
+    Test : we use TSS (Thread Specific Storage). 
+    
+    We have a dummy object that uses TSS.
+    We check to see that every time I request the pointer to an object, on a given thread,
+    the same object is returned.
+
+*/
+
+#define BOOST_LOG_TSS_USE_INTERNAL
+// this includes tss_value class
+#include <boost/logging/logging.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/xtime.hpp>
+#include <sstream>
+#include <string>
+#include <iostream>
+
+struct object_count {
+    typedef boost::mutex mutex;
+    typedef mutex::scoped_lock scoped_lock;
+
+    object_count() : m_count(0) {
+    }
+
+    ~object_count() {
+        scoped_lock lk(m_cs);
+    }
+
+    int increment() {
+        scoped_lock lk(m_cs);
+        return ++m_count;
+    }
+
+    void decrement() {
+        scoped_lock lk(m_cs);
+        --m_count;
+        BOOST_ASSERT(m_count >= 0);
+    }
+
+    int count() const { 
+        scoped_lock lk(m_cs);
+        return m_count; 
+    }
+
+private:
+    mutable mutex m_cs;
+    int m_count;
+};
+
+
+struct dummy {
+    std::string str;
+};
+
+
+using namespace boost;
+using namespace logging;
+
+void do_sleep(int ms) {
+    xtime next;
+    xtime_get( &next, TIME_UTC);
+    next.nsec += (ms % 1000) * 1000000;
+
+    int nano_per_sec = 1000000000;
+    next.sec += next.nsec / nano_per_sec;
+    next.sec += ms / 1000;
+    next.nsec %= nano_per_sec;
+    thread::sleep( next);
+}
+
+
+object_count g_running_threads_count ;
+
+tss_value<dummy> g_dummy;
+
+void use_dummy_thread() {
+    int thread_idx = g_running_threads_count.increment();
+    std::ostringstream out;
+    out << thread_idx;
+    // note: we want to create a unique string to each thread, so see that
+    //       when manipulating local_str, we're actually manipulating the current thread's dummy object
+    std::string thread_idx_str = out.str();
+
+    dummy * local_dummy = &*g_dummy;
+    std::string & local_str = g_dummy->str;
+    std::string copy_str;
+    
+    // just in case we get an assertion fails - know when
+    int try_idx = 0;
+
+    while ( true) {
+        ++try_idx;
+        do_sleep(10);
+
+        dummy * cur_dummy = &*g_dummy;
+        if ( cur_dummy != local_dummy) {
+            std::cout << "thread " << thread_idx << ": assertion failed - dummy - at try " << try_idx;
+            BOOST_ASSERT( false);
+        }
+
+        local_str += thread_idx_str;
+        copy_str += thread_idx_str;
+        if ( copy_str != g_dummy->str) {
+            std::cout << "thread " << thread_idx << ": assertion failed - local_str - at try " << try_idx;
+            BOOST_ASSERT( false);
+        }
+    }
+
+}
+
+
+
+
+int g_total_thread_count = 20;
+
+int g_run_test_secs = 20;
+
+int main()
+{
+    for ( int i = 0; i < g_total_thread_count ; ++i)
+        thread t( &use_dummy_thread);
+
+    do_sleep( g_run_test_secs * 1000 );
+	return 0;
+}
+
Added: sandbox/logging/lib/logging/tests/test_simple_tss/test_simple_tss.sln
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/tests/test_simple_tss/test_simple_tss.sln	2007-11-03 17:43:34 EDT (Sat, 03 Nov 2007)
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_simple_tss", "test_simple_tss.vcproj", "{E091B1F3-E517-4634-B584-841E18F76631}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{E091B1F3-E517-4634-B584-841E18F76631}.Debug|Win32.ActiveCfg = Debug|Win32
+		{E091B1F3-E517-4634-B584-841E18F76631}.Debug|Win32.Build.0 = Debug|Win32
+		{E091B1F3-E517-4634-B584-841E18F76631}.Release|Win32.ActiveCfg = Release|Win32
+		{E091B1F3-E517-4634-B584-841E18F76631}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
Added: sandbox/logging/lib/logging/tests/test_simple_tss/test_simple_tss.vcproj
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/tests/test_simple_tss/test_simple_tss.vcproj	2007-11-03 17:43:34 EDT (Sat, 03 Nov 2007)
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="test_simple_tss"
+	ProjectGUID="{E091B1F3-E517-4634-B584-841E18F76631}"
+	RootNamespace="test_simple_tss"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=".,../../../.."
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="D:\boosts\boost_1_33_1\bin\boost\libs\thread\build\libboost_thread.lib\vc-8_0\debug\threading-multi"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="1"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\test_simple_tss.cpp"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Modified: sandbox/logging/lib/logging/tests/test_tss/count.h
==============================================================================
--- sandbox/logging/lib/logging/tests/test_tss/count.h	(original)
+++ sandbox/logging/lib/logging/tests/test_tss/count.h	2007-11-03 17:43:34 EDT (Sat, 03 Nov 2007)
@@ -1,3 +1,16 @@
+// Boost Logging library
+//
+// Author: John Torjo, www.torjo.com
+//
+// Copyright (C) 2007 John Torjo (see www.torjo.com for email)
+//
+// Distributed under the Boost Software License, Version 1.0.
+//    (See accompanying file LICENSE_1_0.txt or copy at
+//          http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org for updates, documentation, and revision history.
+// See http://www.torjo.com/log2/ for more details
+
 #ifndef object_count_h
 #define object_count_h
 
@@ -16,7 +29,7 @@
 
     ~object_count() {
         scoped_lock lk(m_cs);
-//        BOOST_ASSERT(m_count == 0);
+        BOOST_ASSERT(m_count == 0);
     }
 
     void increment() {
Modified: sandbox/logging/lib/logging/tests/test_tss/test_tss.cpp
==============================================================================
--- sandbox/logging/lib/logging/tests/test_tss/test_tss.cpp	(original)
+++ sandbox/logging/lib/logging/tests/test_tss/test_tss.cpp	2007-11-03 17:43:34 EDT (Sat, 03 Nov 2007)
@@ -1,6 +1,19 @@
 // test_tss.cpp : Defines the entry point for the console application.
 //
 
+// Boost Logging library
+//
+// Author: John Torjo, www.torjo.com
+//
+// Copyright (C) 2007 John Torjo (see www.torjo.com for email)
+//
+// Distributed under the Boost Software License, Version 1.0.
+//    (See accompanying file LICENSE_1_0.txt or copy at
+//          http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org for updates, documentation, and revision history.
+// See http://www.torjo.com/log2/ for more details
+
 /* 
     Test : we use TSS (Thread Specific Storage). We check to see that there are no objects leaked.
 
Modified: sandbox/logging/lib/logging/tests/test_tss/test_tss_objects.cpp
==============================================================================
--- sandbox/logging/lib/logging/tests/test_tss/test_tss_objects.cpp	(original)
+++ sandbox/logging/lib/logging/tests/test_tss/test_tss_objects.cpp	2007-11-03 17:43:34 EDT (Sat, 03 Nov 2007)
@@ -1,3 +1,15 @@
+// Boost Logging library
+//
+// Author: John Torjo, www.torjo.com
+//
+// Copyright (C) 2007 John Torjo (see www.torjo.com for email)
+//
+// Distributed under the Boost Software License, Version 1.0.
+//    (See accompanying file LICENSE_1_0.txt or copy at
+//          http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org for updates, documentation, and revision history.
+// See http://www.torjo.com/log2/ for more details
 
 // so that we can catch the end of deleting all objects
 #define BOOST_LOG_TEST_TSS
@@ -52,7 +64,7 @@
 
     std::string read_word() {
         ++m_word_idx;
-        if ( m_word_idx < g_thread_count) {
+        if ( m_word_idx <= g_thread_count) {
             std::string word;
             (*m_in) >> word;
             return word;
@@ -108,7 +120,8 @@
     read_file local_file;
     while ( true) {
 
-        std::string word = file->read_word();
+        read_file * file_ptr = &*file;
+        std::string word = file_ptr->read_word();
         std::string local_word = local_file.read_word();
         // it should behave just like a "local" variable
         if ( word != local_word)
Modified: sandbox/logging/lib/logging/tests/test_tss/test_tss_on_end_delete.cpp
==============================================================================
--- sandbox/logging/lib/logging/tests/test_tss/test_tss_on_end_delete.cpp	(original)
+++ sandbox/logging/lib/logging/tests/test_tss/test_tss_on_end_delete.cpp	2007-11-03 17:43:34 EDT (Sat, 03 Nov 2007)
@@ -1,3 +1,15 @@
+// Boost Logging library
+//
+// Author: John Torjo, www.torjo.com
+//
+// Copyright (C) 2007 John Torjo (see www.torjo.com for email)
+//
+// Distributed under the Boost Software License, Version 1.0.
+//    (See accompanying file LICENSE_1_0.txt or copy at
+//          http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org for updates, documentation, and revision history.
+// See http://www.torjo.com/log2/ for more details
 
 // so that we can catch the end of deleting all objects
 #define BOOST_LOG_TEST_TSS