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

/* implementation-defined */

Types

Type Aliases

Name

Description

SettingsInfo

Type that encapsulates the current pair of (to<string>(value), reason)

Member Functions

Name

Description

Snapshot [constructor]

Returns a snapshot of all current setting values. Global settings changes will not be visible in the snapshot, and vice versa.

forEachSetting [virtual]

Iterates over all known settings and calls func(visitorInfo) for each.

forceResetToDefault [virtual]

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.

forceSetFromString [virtual]

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.

getAsString [virtual]

Looks up the current setting information by name.

operator()

Wraps a global FOLLY_SETTING(a, b) and returns a snapshot‐local wrapper.

publish [virtual]

Apply all settings updates from this snapshot to the global state unconditionally.

resetToDefault [virtual]

Reset the value of the setting identified by name to its default value. The reason will be set to "default".

setFromString [virtual]

Look up a setting by name, and update the value from a string representation.

Protected Member Functions

Name

Description

operator=

Assignment operators

get

set

Protected Data Members

Name

at_

snapshotValues_

Created with MrDocs