Skip to content

Commit 3c8ddda

Browse files
committed
update docs with thread safe
1 parent a8e2799 commit 3c8ddda

File tree

6 files changed

+31
-15
lines changed

6 files changed

+31
-15
lines changed

Docs/advanced-guides/configuring-service-provider.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ read comment documentation for details:
1111
:language: C++
1212

1313
Pass the custom options to the ServiceCollection buildServiceProvider method to change produced
14-
service provider behaviour
14+
service provider behavior
1515

1616
.. literalinclude:: ../../Examples/Guides/ConfiguredServiceProvider.cpp
1717
:caption: Examples/Guides/ConfiguredServiceProvider

Docs/getting-started.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Getting Started
22
==========================
33

4+
Main Features
5+
--------------------
6+
7+
* Implementation separation
8+
* Multiple implementations support
9+
* Keyed services
10+
* Service aliases
11+
* Thread safe support
12+
* Strong destruction order support
13+
414
Supported Platforms
515
--------------------
616

Examples/Guides/ConfiguredServiceProvider.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ int main()
3939
options.strongDestructionOrder = true;
4040
options.prebuildSingletons = true;
4141
options.checkServiceGlobalUniqueness = false;
42+
options.threadSafe = true;
4243

4344
ServiceProvider provider = ServiceCollection{}
4445
.addSingleton<IService, Service>()

Include/SevenBit/DI/ServiceProvider.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ namespace sb::di
2323

2424
/**
2525
* @brief Constructs service provider with specified instance provider
26+
* @details If service instance provider is nullptr, constructor throws exception
27+
* @throws sb::di::NullPointerException
2628
*/
2729
explicit ServiceProvider(IServiceInstanceProvider::Ptr instanceProvider)
2830
: _instanceProvider(std::move(instanceProvider))
@@ -40,15 +42,11 @@ namespace sb::di
4042

4143
/**
4244
* @brief Returns inner service instance provider
43-
* @details If service instance provider is nullptr, method throws exception
44-
* @throws sb::di::NullPointerException
4545
*/
4646
[[nodiscard]] const IServiceInstanceProvider &getInstanceProvider() const { return *_instanceProvider; }
4747

4848
/**
4949
* @brief Returns inner service instance provider
50-
* @details If service instance provider is nullptr, method throws exception
51-
* @throws sb::di::NullPointerException
5250
*/
5351
IServiceInstanceProvider &getInstanceProvider() { return *_instanceProvider; }
5452

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323

2424
<br />
2525

26-
## Built With
26+
## Main Features
2727

28-
- [Google Test](https://github.com/google/googletest)
29-
- [Google Benchmark](https://github.com/google/benchmark)
30-
- [Sphinx](https://www.sphinx-doc.org/en/master/)
31-
- [Breathe](https://breathe.readthedocs.io/en/latest/)
32-
- [Quom](https://pypi.org/project/quom/)
28+
- Implementation separation
29+
- Multiple implementations support
30+
- Keyed services
31+
- Service aliases
32+
- Thread safe support
33+
- Strong destruction order support
3334

3435
## Supported Platforms
3536

@@ -236,4 +237,12 @@ actionA, actionB executed.
236237
More examples and tutorials are available on the
237238
[Documentation & Examples](https://7bitDI.readthedocs.io) page
238239

240+
## Built With
241+
242+
- [Google Test](https://github.com/google/googletest)
243+
- [Google Benchmark](https://github.com/google/benchmark)
244+
- [Sphinx](https://www.sphinx-doc.org/en/master/)
245+
- [Breathe](https://breathe.readthedocs.io/en/latest/)
246+
- [Quom](https://pypi.org/project/quom/)
247+
239248
@7bitcoder Sylwester Dawida 2023

Tests/Integration/ThreadSafeTest.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#include <gtest/gtest.h>
22
#include <thread>
33

4-
#include "../Helpers/Classes/Basic.hpp"
5-
#include "../Helpers/Classes/CirularDependency.hpp"
64
#include "../Helpers/Classes/Complex.hpp"
7-
#include <SevenBit/DI/Exceptions.hpp>
85
#include <SevenBit/DI/ServiceCollection.hpp>
96

107
class ThreadSafeTest : public testing::Test
@@ -67,8 +64,9 @@ TEST_F(ThreadSafeTest, ShouldGetSafeServices)
6764
.addScoped<ITestComplexClass6, TestComplexClass6>()
6865
.buildServiceProvider(options);
6966

70-
std::vector<std::thread> threads;
7167
constexpr size_t maxThreads = 50;
68+
std::vector<std::thread> threads;
69+
threads.reserve(maxThreads);
7270
for (size_t i = 0; i < maxThreads; ++i)
7371
{
7472
threads.emplace_back(getSafeServices, std::ref(provider));

0 commit comments

Comments
 (0)