How to synchronize data access, part 2

Yesterday I wrote about How to synchronize data access, you should read it before continuing with this post, it will explain in detail the technique I will expand upon here. I’ll wait… Alright! Now that you understand how a temporary RAII object can lock a mutex associated with an instance of an object, effectively synchronizing […]

How to synchronize data access

I came across a post titled C++ Locking Wrapper shared by Meeting C++ on Twitter and it reminded me of Synchronized Data Structures and boost::synchronized_value so I decided to implement my own version as a learning exercise and possible topic of a future video on my YT channel. The idea is simple: synchronize across multiple […]

Templates, Linking and everything in between

Last weekend, San Diego C++ Meetup hosted Andreas Fertig. Andreas presented his excellent talk on “C++ Templates”. During his talk, one of the attendees asked a question that many, if not all, C++ programmers had asked at least once in their early life as C++ programmers. In this post, I hope it would provide answers […]

How to implement a memory pool

Last week I explained what a memory pool is and how to use it. This week my lesson was about implementing a simple memory pool capable of fixed size memory chunk allocations. The pool preallocates a block of memory on demand, carves out equal sized chunks from it, and returns a raw pointer each time […]

How to use memory pools

In this week’s class I explained what memory pools are and how to use them to optimize frequent allocations and deallocations of objects. I also demonstrated how to overwrite operator new / operator new [] and operator delete / operator delete [] for a struct / class type.The code for this class contains a simple benchmark which measures pool’s performance against […]

How to detect memory leaks

During my last week’s class I discussed a source-code method of finding memory leaks in C++. What do I mean by that? Source-code method is not a way of debugging a process like one could do with Valgrind on Linux or Deleaker on Windows (which I’ve used recently and really enjoyed its integration with Visual […]

26th San Diego C++ Meetup

The 26th Meetup of the San Diego C++ Group was held on May 18th, 2021 and featured guest speaker Arno Schödl, Founder & CTO of think-cell who spoke about A Practical Approach to Error Handling.

25th San Diego C++ Meetup

The 25th Meetup of the San Diego C++ Group was held on April 27th, 2021 and featured guest speaker Jerry Wiltse from the Conan Package Manager Team. The recording and slides of the presentation can be found here.

How to implement a spinlock / event / semaphore

Multi-threading has been the theme of my previous two classes where I discussed thread-pools and producer-consumer queues. Let’s talk about the fundamental aspects of multi-threading and some of its most basic building blocks: spinlocks, automatic and manual events, and semaphores.In this week’s class I will show you how to implement these building blocks using only […]

How to implement a producer-consumer queue

During my most recent class I discussed implementations of simple, multi-threaded, producer-consumer queues: unbounded (can grow in size indefinitely) and bounded (can only grow to a certain size). In short: the unbounded queue will block consumers’ pop() calls if it happens to be empty until a producer pushes something onto it. Bounded queue will do […]

How to implement a thread pool

By popular demand, and at the request of my coworkers, this week’s class was about implementing a simple thread pool using only standard C++ components. It would have taken 1h-30m if I didn’t completely forget how to use a condition variable. It’s 2h long!Bad std::condition_variable.wait(...) predicate caused a deadlock and I spent 30 minutes trying […]

Light-weight RPC framework

During my latest mentoring session with coworkers I was asked to explain how modern RPC frameworks work under the hood. What better way to illustrate this than to build one from scratch using components I blogged about previously (event objects, serializer framework, and TCP sockets). Although not part of the video recording (which I will […]

Case insensitive string, etc

The question of case insensitive strings has been, and continues to be asked a lot, and equally many answers can be found all over the internet. The go-to solution is to create a char_traits policy class with eq, lt, and compare methods implemented using std::toupper before comparing characters, then instantiate std::basic_string with it using istring = std::basic_string<char, char_itraits<char>> This […]

Welcome, Kobi!

I would like to extend a warm welcome to fellow C++ enthusiast, and blog contributor, Kobi! Many of you know him from his Twitter account or as the organizer of San Diego C++ Meetup. We have been exchanging likes and occasional comments on Twitter ever since I started this blog. He has always been encouraging […]

Function alias vs Function pointer alias

Last weekend (4/4/2021) I was sitting down and working on my San Diego C++ agenda for the 25th upcoming session. One of things I really like presenting is few riddles from cppquiz.org I stumbled upon this one: https://cppquiz.org/quiz/question/227 . Simple and easy one. Here is the code in question: And the question is what is […]

std::deep_ptr

std::deep_ptr aka deep copying smart pointer has not yet been introduced to the STL though several C++ experts have proposed an implementation in the past. See n3339.pdf for one such proposal and a list of possible implementations. In this post I want to share my implementation of deep copying pointer I recently came up with. […]

San Diego C++ Meetup

San Diego C++ Meetup 25th meeting featuring JFrog and Conan! Agenda Welcome slides – goals we would like to achieve in San Diego C++ MeetupThis meeting – Hosting JFrog: Conan Package Manager for C++ in Practice If time permits:* Shout Out to a great C++ blog – “Vorbrodt’s C++ Blog”* 3 cppquiz questions* 2 years […]

Fun with TCP sockets

The purpose of this post is not to teach you about posix sockets; there’s plenty of that already. Instead I want to share two simple classes I implemented last night which encapsulate two types of tcp sockets: listening server socket and a client socket. These sockets as well as my recent serializer code will be […]