std::condition_variable condition variable and lock_guard, unique_lock

Used to block one thread, or block multiple threads at the same time, until another thread modifies the shared variable (condition) and notifies condition_variable. A thread that intentionally modifies a variable must Obtain std::mutex (often via std::lock_guard ) Modify while holding lock Perform notify_one or notify_all on std::condition_variable (no need to hold locks for notifications) […]

The use of C++ smart pointers: the use of shared_ptr, weak_ptr, unique_ptr, use case description.

Directory of series articles Contents of this chapter: (1) Introduction to shared_ptr, weak_ptr, unique_ptr (2) Memory leak caused by using share_ptr alone (3) Combined use of shared_ptr and weak_ptr Article directory Table of Contents of Series Articles Preface 1. Use of shared_ptr, weak_ptr, unique_ptr 1.1 shared_ptr 1.2 weak_ptr 1. Creation of weak_ptr pointer 2. Member […]

Cache (Redis) tool class, including solutions for cache breakdown, cache penetration, and generation of globally unique IDs

Cache (Redis) tool class, including solutions for cache breakdown, cache penetration, and generation of globally unique ids /** * Cache (Redis) tool class, including solutions for cache breakdown, cache penetration, and generation of globally unique IDs * */ public class CacheManipulate {<!– –> //Generate the variables required for global id public static final long BEGIN_TIMESTEMP […]

Spring annotation magic: the perfect solution for uniqueness verification of object properties in collections

Spring Boot provides a powerful validation framework, but sometimes we need to create custom validation rules according to our own business needs. This article will introduce how to use Spring Boot custom annotations, validators, and reflection to check whether the value of a certain attribute of each object in the collection is unique. 1. Custom […]

[C++11] Use of smart pointers and simulation implementation (shared_ptr, unique_ptr, auto_ptr, weak_ptr)

Blog homepage: Homepage Series column: C + + Thank you everyone for your likesCollections?Comments Looking forward to making progress with everyone! Article directory 1. RAII concept 1. auto_ptr 1.Basic use 2. Simulation implementation 2. unique_ptr 1.Basic use 2. Simulation implementation 3. shared_ptr 1.Basic use 2. Reference counting implementation 3. Upgrade of destructor (for arrays) 4. […]

Inability to read with the naked eye is the unique romance of binary – a blog to learn about file operations (C language)

Table of Contents 1. Why use files 2. What is a file? 2.1 Program files 2.2 Data files 2.3 Text files and binary files 2.4 File name 3. Opening and closing files 3.1 File pointer 3.2 Opening and closing files 3.3 Sequential reading and writing functions of files 3.3.1 The concept of flow 3.3.2 Concept […]

C++ smart pointers (3) – a preliminary study on unique_ptr

Unlike the shared pointer shared_ptr, which is used for shared objects, unique_ptr is used for exclusive objects. Article directory 1. Purpose of unqiue_ptr 2. Use unique_ptr 2.1 Initialize unique_ptr 2.2 Access data 2.3 As a member of a class 2.4 Processing arrays 3. Transfer of ownership 3.1 Simple syntax 3.2 Transfer ownership between functions 3.2.1 […]

[Yugong Series] October 2023 .NET CORE tool case-DeveloperSharp (distributed unique ID)

About the author, Yu Gong moves the code “Title”: Huawei Cloud Special Editor, Huawei Cloud Cloud Enjoyment Expert, Huawei Developer Expert, Huawei Product Cloud Testing Expert, CSDN Blog Expert, Alibaba Cloud Expert Blogger, Tencent Cloud Excellent Blogger, Nuggets Excellent Blogger, 51CTO Blogging experts and more. “Recent Honors”: CSDN Blog Star TOP2 in 2022, Huawei Cloud […]