Code Explainers

Code explainers tagged #mutex

rust
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use std::thread;
 

Aggregating metrics across threads in Rust

concurrency shared-state mutex
Intermediate 7 steps
go
package debounce
 
import (
	"sync"

Building a debouncer in Go

concurrency debounce timers
Intermediate 6 steps
ruby
class Throttle
  def initialize(interval)
    @interval = interval
    @mutex = Mutex.new

A thread-safe throttle in Ruby

concurrency rate-limiting mutex
Intermediate 7 steps
ruby
class ThreadSafeCounter
  def initialize(initial = 0)
    @count = initial
    @mutex = Mutex.new

A thread-safe counter with Mutex in Ruby

concurrency mutex thread-safety
Intermediate 6 steps
go
package main
 
import "sync"
 

Mutex vs RWMutex in Go

concurrency mutex synchronization
Intermediate 6 steps