[CXX-995] Add mongocxx::pool examples Created: 17/Aug/16 Updated: 15/Mar/17 Resolved: 08/Mar/17 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | Documentation |
| Affects Version/s: | None |
| Fix Version/s: | 3.2.0-rc0 |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | David Golden | Assignee: | Samuel Rossi (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
We have no examples of pool usage for multi-threaded operation and we should have some. At a minimum, it should show:
|
| Comments |
| Comment by Githook User [ 15/Mar/17 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'xdg', u'name': u'David Golden', u'email': u'xdg@xdg.me'}Message: Newer libmongoc has stricter connection string parsing. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 08/Mar/17 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'saghm', u'name': u'Saghm Rossi', u'email': u'saghmrossi@gmail.com'}Message: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by chen shu [ 22/Nov/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
My code,
my_app.cc file
2. create the MyApp object and set the pool to its member in main function(main.cc file)
3. In any thread function, use the following to get connection from pool
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by David Golden [ 17/Aug/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sorry, I meant that the example should have a comment to the effect that when the object goes out of scope, it will be returned to the pool automatically. There's no 'return to pool' call. I assume that's expected by experienced C++ programmers, but the examples ought to be newbie friendly. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 17/Aug/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
You don't actually need to demo RAII since the objects handed back from the mongocxx::pool are unique_ptrs. |