Captures the current state of all setting values and allows updating multiple settings at once, with verification and rollback.
Synopsis
Declared in <folly/settings/Settings.h>
class Snapshot final
: public /* implementation-defined */
Description
A single snapshot cannot be used concurrently from different threads. Multiple concurrent snapshots are safe. Passing a single snapshot from one thread to another is safe as long as the user properly synchronizes the handoff.
Example usage:
folly::settings::Snapshot snapshot; // FOLLY_SETTING(project, name) refers to the globally visible value // snapshot(FOLLY_SETTING(project, name)) refers to the value saved in the // snapshot FOLLY_SETTING(project, name).set(new_value); assert(*FOLLY_SETTING(project, name) == new_value); assert(*snapshot(FOLLY_SETTING(project, name)) == old_value);
snapshot(FOLLY_SETTING(project, name)).set(new_snapshot_value); assert(*FOLLY_SETTING(project, name) == new_value); assert(*snapshot(FOLLY_SETTING(project, name)) == new_snapshot_value);
// At this point we can discard the snapshot and forget new_snapshot_value, // or choose to publish: snapshot.publish(); assert(*FOLLY_SETTING(project, name) == new_snapshot_value);
Base Classes
Name |
Description |
|
Types
Name |
Type Aliases
Name |
Description |
Type that encapsulates the current pair of (to<string>(value), reason) |
Member Functions
Name |
Description |
|
Returns a snapshot of all current setting values. Global settings changes will not be visible in the snapshot, and vice versa. |
|
Iterates over all known settings and calls func(visitorInfo) for each. |
|
Same as resetToDefault but will reset frozen immutables in this snapshot. However, it will still not publish them. This is mainly useful for setting change dry‐runs. |
|
Same as setFromString but will set frozen immutables in this snapshot. However, it will still not publish them. This is mainly useful for setting change dry‐runs. |
|
Looks up the current setting information by name. |
Wraps a global FOLLY_SETTING(a, b) and returns a snapshot‐local wrapper. |
|
|
Apply all settings updates from this snapshot to the global state unconditionally. |
|
Reset the value of the setting identified by name to its default value. The reason will be set to "default". |
|
Look up a setting by name, and update the value from a string representation. |
Protected Member Functions
Name |
Description |
Assignment operators |
|
Protected Data Members
Name |
Created with MrDocs