Summary: To emulate the `ThreadSafe` contract in C++/ObjC, reporting was gated behind a check that ensured a C++/ObjC class has a `std::mutex` member (plus other filters). This is reasonable, but it has some drawbacks - other locks may be used, and therefore must be added to the member check; - locking mechanisms that use the object itself as a monitor cannot be modelled (`synchronized` in ObjC) RacerD already has `ThreadsDomain` which models our guess on whether a method is expected to run in a concurrent context, and which in C++/ObjC boils down to whether the method non-transitively acquires a lock. This should be a good enough indicator that the class should be checked regardless of whether the locks are member fields. This diff gates the C++/ObjC check on that abstract property. Reviewed By: dulmarod Differential Revision: D19558355 fbshipit-source-id: 229d7ff82master
parent
5510223850
commit
777eb33870
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
#include <mutex>
|
||||
|
||||
namespace without_mutex {
|
||||
|
||||
class WithoutMutex {
|
||||
public:
|
||||
WithoutMutex() {}
|
||||
|
||||
int get() { return field_1; }
|
||||
|
||||
int set(std::mutex& mutex, int data) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
field_1 = data;
|
||||
}
|
||||
|
||||
private:
|
||||
int field_1;
|
||||
};
|
||||
} // namespace without_mutex
|
Loading…
Reference in new issue