Skip to content

Curve/lockpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

62 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


A C++23 library providing mutex protection for any object

๐Ÿ“ฆ Installation

  • Using CPM

    CPMFindPackage(
      NAME           lockpp
      VERSION        3.2.0
      GIT_REPOSITORY "https://github.com/Curve/lockpp"
    )
  • Using FetchContent

    include(FetchContent)
    
    FetchContent_Declare(lockpp GIT_REPOSITORY "https://github.com/Curve/lockpp" GIT_TAG v3.2.0)
    FetchContent_MakeAvailable(lockpp)
    
    target_link_libraries(<target> cr::lockpp)

๐Ÿ“ƒ Usage

lockpp::lock<std::string> var("Test");

// Read only access
{
    auto locked = var.read();
    assert(!locked->empty());
}

// Write access
{
    auto locked = var.write();

    *write_access = "assignment";
    locked->clear();
}

// One time access
var.assign("another assignment");
assert(var.copy() == "another assignment");

lockpp also allows you to supply the mutex to be used as well as custom locks (i.e std::unique_lock, std::lock_guard).

For more examples see tests

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy