Skip to content

Unnecessary use of Once? #253

@Kriskras99

Description

@Kriskras99

To allow configuring the memory limit and human readable (de)serialisation we currently use std::sync::Once:

static MAX_ALLOCATION_BYTES_ONCE: Once = Once::new();

static SERDE_HUMAN_READABLE_ONCE: Once = Once::new();

Once is a low-level primitive and although correct not really the right tool for the job (anymore). Something like OnceLock::get_or_init provides the same functionality as Once + AtomicUsize/Bool in a much nicer API.

But I also think only allowing it to be set once is not necessarily the right thing either. I can imagine a program that might want to increase its limit if it encounters files that are too large iff the computer it's running on has spare resources.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions