[SERVER-4974] better document thread safety of BSONObj Created: 15/Feb/12  Updated: 10/May/22

Status: Backlog
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Aaron Staple Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Unresolved Votes: 0
Labels: move-sa, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

There's a comment at the top of BSONObj about thread safety that seems out of date.

       Note that BSONObj's have a smart pointer capability built in -- so you can
       pass them around by value.  The reference counts used to implement this
       do not use locking, so copying and destroying BSONObj's are not thread-safe
       operations.

It looks like references are counted via AtomicUInt so the counting seems thread safe. And it looks like the thread safety rules are similar to those for shared_ptr, but it would be good to check that and document.



 Comments   
Comment by Steven Vannelli [ 10/May/22 ]

Moving this ticket to the Backlog and removing the "Backlog" fixVersion as per our latest policy for using fixVersions.

Comment by Mira Carey [ 15/Mar/16 ]

The work here is to change the comment at the top of BSONObj

Generated at Thu Feb 08 03:07:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.