Flutter Engine
Loading...
Searching...
No Matches
atomic_object.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_FML_SYNCHRONIZATION_ATOMIC_OBJECT_H_
6
#define FLUTTER_FML_SYNCHRONIZATION_ATOMIC_OBJECT_H_
7
8
#include <mutex>
9
10
namespace
fml
{
11
12
// A wrapper for an object instance that can be read or written atomically.
13
template
<
typename
T>
14
class
AtomicObject
{
15
public
:
16
AtomicObject
() =
default
;
17
explicit
AtomicObject
(T
object
) : object_(
std
::move(object)) {}
18
19
T
Load
()
const
{
20
std::scoped_lock lock(mutex_);
21
return
object_;
22
}
23
24
void
Store
(
const
T&
object
) {
25
std::scoped_lock lock(mutex_);
26
object_ = object;
27
}
28
29
private
:
30
mutable
std::mutex mutex_;
31
T object_;
32
};
33
34
}
// namespace fml
35
36
#endif
// FLUTTER_FML_SYNCHRONIZATION_ATOMIC_OBJECT_H_
fml::AtomicObject
Definition
atomic_object.h:14
fml::AtomicObject::Load
T Load() const
Definition
atomic_object.h:19
fml::AtomicObject::AtomicObject
AtomicObject(T object)
Definition
atomic_object.h:17
fml::AtomicObject::Store
void Store(const T &object)
Definition
atomic_object.h:24
fml::AtomicObject::AtomicObject
AtomicObject()=default
fml
Definition
ascii_trie.cc:9
std
Definition
ref_ptr.h:261
fml
synchronization
atomic_object.h
Generated on Thu Nov 6 2025 16:11:22 for Flutter Engine by
1.9.8