Boost logo

Boost-Commit :

From: john.groups_at_[hidden]
Date: 2007-11-01 13:08:42


Author: jtorjo
Date: 2007-11-01 13:08:41 EDT (Thu, 01 Nov 2007)
New Revision: 40648
URL: http://svn.boost.org/trac/boost/changeset/40648

Log:
[logging]
v0.9.12.3, 1 nov 2007
- move ts/* files to detail directory

Added:
   sandbox/logging/boost/logging/detail/ts/
   sandbox/logging/boost/logging/detail/ts/ts.hpp (contents, props changed)
   sandbox/logging/boost/logging/detail/ts/ts_boost.hpp (contents, props changed)
   sandbox/logging/boost/logging/detail/ts/ts_none.hpp (contents, props changed)
   sandbox/logging/boost/logging/detail/ts/ts_posix.hpp (contents, props changed)
   sandbox/logging/boost/logging/detail/ts/ts_resource.hpp (contents, props changed)
   sandbox/logging/boost/logging/detail/ts/ts_win32.hpp (contents, props changed)
Removed:
   sandbox/logging/boost/logging/ts/
Text files modified:
   sandbox/logging/boost/logging/defaults.hpp | 4 ++--
   sandbox/logging/boost/logging/detail/fwd.hpp | 4 ++--
   sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp | 4 +++-
   3 files changed, 7 insertions(+), 5 deletions(-)

Modified: sandbox/logging/boost/logging/defaults.hpp
==============================================================================
--- sandbox/logging/boost/logging/defaults.hpp (original)
+++ sandbox/logging/boost/logging/defaults.hpp 2007-11-01 13:08:41 EDT (Thu, 01 Nov 2007)
@@ -20,8 +20,8 @@
 # pragma once
 #endif
 
-#include <boost/logging/ts/ts.hpp>
-#include <boost/logging/ts/ts_resource.hpp>
+#include <boost/logging/detail/ts/ts.hpp>
+#include <boost/logging/detail/ts/ts_resource.hpp>
 
 #include <string>
 #include <boost/config.hpp>

Modified: sandbox/logging/boost/logging/detail/fwd.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/fwd.hpp (original)
+++ sandbox/logging/boost/logging/detail/fwd.hpp 2007-11-01 13:08:41 EDT (Thu, 01 Nov 2007)
@@ -21,8 +21,8 @@
 # pragma once
 #endif
 
-#include <boost/logging/ts/ts.hpp>
-#include <boost/logging/ts/ts_resource.hpp>
+#include <boost/logging/detail/ts/ts.hpp>
+#include <boost/logging/detail/ts/ts_resource.hpp>
 #include <boost/logging/detail/util.hpp>
 
 #include <boost/logging/defaults.hpp>

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-01 13:08:41 EDT (Thu, 01 Nov 2007)
@@ -1,7 +1,9 @@
 /**
 @page page_changelog Changelog
 
-v0.9.12.2, 1 nov 2007
+v0.9.12.3, 1 nov 2007
+- move ts/* files to detail directory
+- doc - standalone page with changelog
 - moved changelog.hpp to detail/raw_doc dir
 
 v0.9.11, 31 oct 2007

Added: sandbox/logging/boost/logging/detail/ts/ts.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/ts/ts.hpp 2007-11-01 13:08:41 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,70 @@
+// ts.hpp
+
+// 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 JT28092007_BOOST_LOG_TS_HPP
+#define JT28092007_BOOST_LOG_TS_HPP
+
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/config.hpp>
+
+#ifdef BOOST_HAS_THREADS
+
+ #ifdef BOOST_LOG_USE_BOOST_THREADS
+ #include <boost/logging/detail/ts/ts_boost.hpp>
+ #else
+ #ifdef BOOST_WINDOWS
+ #include <boost/logging/detail/ts/ts_win32.hpp>
+ #else
+ #include <boost/logging/detail/ts/ts_posix.hpp>
+ #endif
+ #endif
+
+#else
+ // no threads
+ #include <boost/logging/detail/ts/ts_none.hpp>
+#endif
+
+
+
+namespace boost { namespace logging { namespace threading {
+
+#ifdef BOOST_HAS_THREADS
+
+ #ifdef BOOST_LOG_USE_BOOST_THREADS
+ typedef mutex_boost mutex;
+ #else
+ #ifdef BOOST_WINDOWS
+ typedef mutex_win32 mutex;
+ #else
+ typedef mutex_posix mutex;
+ #endif
+ #endif
+
+#else
+ // no threads
+ typedef no_mutex mutex;
+#endif
+
+
+typedef mutex::scoped_lock scoped_lock;
+
+}}}
+
+#endif
+

Added: sandbox/logging/boost/logging/detail/ts/ts_boost.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/ts/ts_boost.hpp 2007-11-01 13:08:41 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,39 @@
+// ts_boost.hpp
+
+// 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 JT28092007_BOOST_LOG_TS_HPP_boost
+#define JT28092007_BOOST_LOG_TS_HPP_boost
+
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/thread/mutex.hpp>
+
+
+namespace boost { namespace logging {
+
+namespace threading {
+
+ typedef boost::mutex mutex_boost;
+ typedef mutex::scoped_lock scoped_lock_boost;
+}
+
+}}
+
+
+#endif
+

Added: sandbox/logging/boost/logging/detail/ts/ts_none.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/ts/ts_none.hpp 2007-11-01 13:08:41 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,49 @@
+// ts_none.hpp
+
+// 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 JT28092007_BOOST_LOG_TS_HPP_none
+#define JT28092007_BOOST_LOG_TS_HPP_none
+
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+
+namespace boost { namespace logging {
+
+namespace threading {
+ // no threads
+ struct no_mutex ;
+
+ struct no_lock {
+ no_lock(no_mutex &) {}
+ };
+
+ struct no_mutex {
+ typedef no_lock scoped_lock;
+ void Lock() {}
+ void Unlock() {}
+ };
+
+
+}
+
+}}
+
+
+#endif
+

Added: sandbox/logging/boost/logging/detail/ts/ts_posix.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/ts/ts_posix.hpp 2007-11-01 13:08:41 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,118 @@
+// ts_posix.hpp
+
+// 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
+
+
+
+// Copyright (C) 2001-2003
+// William E. Kempf
+//
+// Permission to use, copy, modify, distribute and sell this software
+// and its documentation for any purpose is hereby granted without fee,
+// provided that the above copyright notice appear in all copies and
+// that both that copyright notice and this permission notice appear
+// in supporting documentation. William E. Kempf makes no representations
+// about the suitability of this software for any purpose.
+// It is provided "as is" without express or implied warranty.
+
+
+#ifndef JT28092007_BOOST_LOG_TS_HPP_posix
+#define JT28092007_BOOST_LOG_TS_HPP_posix
+
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdexcept>
+#include <cassert>
+
+namespace boost { namespace logging {
+
+namespace threading {
+
+class scoped_lock_posix ;
+
+class mutex_posix {
+
+ mutex_posix & operator = ( const mutex_posix & Not_Implemented);
+ mutex_posix( const mutex_posix & From);
+public:
+ typedef scoped_lock_posix scoped_lock;
+
+ mutex_posix() : m_mutex() {
+ pthread_mutexattr_t attr;
+ int res = pthread_mutexattr_init(&attr);
+ assert(res == 0);
+
+ res = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+ assert(res == 0);
+
+ res = pthread_mutex_init(&m_mutex, &attr);
+ {
+ int res = pthread_mutexattr_destroy(&attr);
+ assert(res == 0);
+ }
+ if (res != 0)
+ throw std::runtime_error("could not create mutex_posix");
+ }
+ ~mutex_posix() {
+ int res = 0;
+ res = pthread_mutex_destroy(&m_mutex);
+ assert(res == 0);
+ }
+
+ void Lock() {
+ int res = 0;
+ res = pthread_mutex_lock(&m_mutex);
+ assert(res == 0);
+ if (++m_count > 1)
+ {
+ res = pthread_mutex_unlock(&m_mutex);
+ assert(res == 0);
+ }
+ }
+ void Unlock() {
+ if (--m_count == 0)
+ {
+ int res = 0;
+ res = pthread_mutex_unlock(&m_mutex);
+ assert(res == 0);
+ }
+ }
+private:
+ pthread_mutex_t m_mutex;
+ unsigned m_count;
+};
+
+class scoped_lock_posix {
+ scoped_lock_posix operator=( scoped_lock_posix & Not_Implemented);
+ scoped_lock_posix( const scoped_lock_posix & Not_Implemented);
+public:
+ scoped_lock_posix( mutex_posix & cs) : m_cs( cs) { m_cs.Lock(); }
+ ~scoped_lock_posix() { m_cs.Unlock(); }
+private:
+ mutex_posix & m_cs;
+};
+
+
+}
+
+}}
+
+
+#endif
+

Added: sandbox/logging/boost/logging/detail/ts/ts_resource.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/ts/ts_resource.hpp 2007-11-01 13:08:41 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,158 @@
+// ts_resource.hpp
+
+// 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 JT28092007_ts_resource_HPP_DEFINED
+#define JT28092007_ts_resource_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/detail/ts/ts.hpp>
+
+namespace boost { namespace logging {
+
+/**
+ @brief Contains implementations of locker objects. Such a locker can lock data for read or write.
+
+ Assume you have
+ @code
+ struct data {
+ std::string name;
+ std::string desc;
+ };
+
+ some_locker<data> lk;
+ @endcode
+
+
+ In order to access the locked data for write, you do:
+
+ @code
+ some_locker<data>::write obj(lk);
+ obj->name = "coolio";
+ obj->desc = "it works!";
+ @endcode
+
+ In order to access the locked data for read, you do:
+ @code
+ some_locker<data>::read obj(lk);
+ std::cout << obj->name << "/" << obj->desc;
+ @endcode
+
+*/
+namespace locker {
+
+ /**
+ the data to be locked. It's locked using default thread-safety
+
+ @sa locker
+ */
+ template<class type, class mutex = boost::logging::threading::mutex > struct ts_resource {
+ typedef ts_resource<type,mutex> self_type;
+
+ ts_resource(const type& val = type() ) : m_val(val) {}
+
+ struct read;
+ struct write;
+ friend struct read;
+ friend struct write;
+
+ struct write {
+ self_type & self ;
+ write(self_type & self) : self(self) {
+ self.m_cs.Lock();
+ }
+ ~write() {
+ self.m_cs.Unlock();
+ }
+
+ type & use() { return self.m_val ; }
+ type* operator->() { return &use(); }
+ };
+
+ struct read {
+ const self_type & self ;
+ read(const self_type & self) : self(self) {
+ self.m_cs.Lock();
+ }
+ ~read() {
+ self.m_cs.Unlock();
+ }
+
+ const type & use() { return self.m_val ; }
+ const type* operator->() { return &use(); }
+ };
+
+
+ private:
+ mutable mutex m_cs;
+ type m_val;
+ };
+
+ /**
+ Locks a resource, and uses TLS. This holds the value, and each thread caches it.
+ Once at a given period (like, every 5 seconds), when used, the latest object is copied.
+
+ @sa locker
+ */
+ template<class type> struct tls_resource_with_cache {
+ // FIXME - implement using TLS!!!
+
+ typedef tls_resource_with_cache<type> self_type;
+
+ tls_resource_with_cache(const type& val , int /* cache_millis */ ) : m_val(val) {}
+
+
+ public:
+ struct read;
+ struct write;
+ friend struct read;
+ friend struct write;
+
+ struct write {
+ self_type & self ;
+ write(self_type & self) : self(self) {
+ }
+ ~write() {
+ }
+
+ type & use() { return self.m_val ; }
+ type* operator->() { return &use(); }
+ };
+
+ struct read {
+ const self_type & self ;
+ read(const self_type & self) : self(self) {
+ }
+ ~read() {
+ }
+
+ const type & use() { return self.m_val ; }
+ const type* operator->() { return &use(); }
+ };
+
+
+
+ private:
+ type m_val;
+ };
+
+
+}}}
+
+#endif
+

Added: sandbox/logging/boost/logging/detail/ts/ts_win32.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/ts/ts_win32.hpp 2007-11-01 13:08:41 EDT (Thu, 01 Nov 2007)
@@ -0,0 +1,73 @@
+// ts_win32.hpp
+
+// 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 JT28092007_BOOST_LOG_TS_HPP_win32
+#define JT28092007_BOOST_LOG_TS_HPP_win32
+
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+// many thanks to Terris Linerbach!
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+
+
+namespace boost { namespace logging { namespace threading {
+
+class scoped_lock_win32 ;
+
+class mutex_win32 {
+
+ mutex_win32 & operator = ( const mutex_win32 & Not_Implemented);
+ mutex_win32( const mutex_win32 & From);
+public:
+ typedef scoped_lock_win32 scoped_lock;
+
+ mutex_win32() {
+ InitializeCriticalSection( GetCriticalSectionPtr() );
+ }
+ ~mutex_win32() {
+ DeleteCriticalSection(GetCriticalSectionPtr());
+ }
+ void Lock() {
+ EnterCriticalSection( GetCriticalSectionPtr());
+ }
+ void Unlock() {
+ LeaveCriticalSection( GetCriticalSectionPtr());
+ }
+private:
+ LPCRITICAL_SECTION GetCriticalSectionPtr() const { return &m_cs; }
+ mutable CRITICAL_SECTION m_cs;
+};
+
+class scoped_lock_win32 {
+ scoped_lock_win32 operator=( scoped_lock_win32 & Not_Implemented);
+ scoped_lock_win32( const scoped_lock_win32 & Not_Implemented);
+public:
+ scoped_lock_win32( mutex_win32 & cs) : m_cs( cs) { m_cs.Lock(); }
+ ~scoped_lock_win32() { m_cs.Unlock(); }
+private:
+ mutex_win32 & m_cs;
+};
+
+}}}
+
+#endif
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk