|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53962 - in sandbox/monotonic: boost/monotonic libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-15 23:37:03
Author: cschladetsch
Date: 2009-06-15 23:37:02 EDT (Mon, 15 Jun 2009)
New Revision: 53962
URL: http://svn.boost.org/trac/boost/changeset/53962
Log:
added shared_storage
Added:
sandbox/monotonic/boost/monotonic/shared_storage.h (contents, props changed)
sandbox/monotonic/libs/monotonic/test/test_shared_storage.cpp (contents, props changed)
Text files modified:
sandbox/monotonic/libs/monotonic/test/main.cpp | 2 ++
sandbox/monotonic/libs/monotonic/test/monotonic.vcproj | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
Added: sandbox/monotonic/boost/monotonic/shared_storage.h
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/monotonic/shared_storage.h 2009-06-15 23:37:02 EDT (Mon, 15 Jun 2009)
@@ -0,0 +1,74 @@
+// Copyright (C) 2009 Christian Schladetsch
+//
+// 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)
+
+#pragma once
+
+#include <boost/monotonic/storage.h>
+#include <boost/thread/mutex.hpp>
+
+namespace boost
+{
+ namespace monotonic
+ {
+ /// thread-safe storage
+ template <size_t InlineSize = 8*1024, size_t MinHeapSize = InlineSize*1000, class Al = std::allocator<char> >
+ struct shared_storage : storage_base
+ {
+ typedef storage<InlineSize, MinHeapSize, Al> Storage;
+ private:
+ Storage storage;
+ mutex guard;
+
+ public:
+ shared_storage()
+ {
+ }
+ shared_storage(Al const &A)
+ : storage(A)
+ {
+ }
+ size_t used() const
+ {
+ mutex::scoped_lock lock(guard);
+ return storage.used();
+ }
+ void reset()
+ {
+ mutex::scoped_lock lock(guard);
+ return storage.reset();
+ }
+ void *allocate(size_t num_bytes, size_t alignment)
+ {
+ mutex::scoped_lock lock(guard);
+ return storage.allocate(num_bytes, alignment);
+ }
+ void deallocate(void *, size_t)
+ {
+ // do nothing
+ }
+ size_t remaining() const
+ {
+ mutex::scoped_lock lock(guard);
+ return storage.remaining();
+ }
+ size_t fixed_remaining() const
+ {
+ mutex::scoped_lock lock(guard);
+ return storage.fixed_remaining();
+ }
+ size_t max_size() const
+ {
+ mutex::scoped_lock lock(guard);
+ return storage.max_size();
+ }
+
+ };
+
+ } // namespace monotonic
+
+} // namespace boost
+
+//EOF
+
Modified: sandbox/monotonic/libs/monotonic/test/main.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/main.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/main.cpp 2009-06-15 23:37:02 EDT (Mon, 15 Jun 2009)
@@ -395,9 +395,11 @@
#include "test_bubble_sort.cpp"
#include "test_dupe.cpp"
#include "test_chained_storage.cpp"
+#include "test_shared_storage.cpp"
int main()
{
+ test_shared_storage();
test_chained_storage();
test_map_list_heap_stack();
test_dupe();
Modified: sandbox/monotonic/libs/monotonic/test/monotonic.vcproj
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/monotonic.vcproj (original)
+++ sandbox/monotonic/libs/monotonic/test/monotonic.vcproj 2009-06-15 23:37:02 EDT (Mon, 15 Jun 2009)
@@ -182,6 +182,10 @@
>
</File>
<File
+ RelativePath="..\..\..\boost\monotonic\fixed_storage.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\boost\monotonic\inline_clone_allocator.h"
>
</File>
@@ -202,6 +206,10 @@
>
</File>
<File
+ RelativePath="..\..\..\boost\monotonic\shared_storage.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\boost\monotonic\storage.h"
>
</File>
@@ -343,6 +351,18 @@
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath=".\test_shared_storage.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
</Files>
<Globals>
</Globals>
Added: sandbox/monotonic/libs/monotonic/test/test_shared_storage.cpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/libs/monotonic/test/test_shared_storage.cpp 2009-06-15 23:37:02 EDT (Mon, 15 Jun 2009)
@@ -0,0 +1,8 @@
+//#include <boost/monotonic/shared_storage.h>
+//
+void test_shared_storage()
+{
+ // TODO!
+}
+//
+////EOF
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