Code Explainers

Code explainers tagged #channels

rust
use std::sync::{mpsc, Arc, Mutex};
use std::thread;
use std::time::Duration;
 

Building a thread pool in Rust

concurrency channels thread-pool
Advanced 9 steps
go
package main
 
import (
	"context"

Graceful HTTP shutdown in Go

graceful-shutdown signals goroutines
Intermediate 8 steps
go
func StreamMetrics(c *gin.Context) {
	clientGone := c.Request.Context().Done()
	ticker := time.NewTicker(time.Second)
	defer ticker.Stop()

Streaming server-sent events in Gin

server-sent-events streaming channels
Intermediate 7 steps
go
package worker
 
import (
	"fmt"

A graceful worker pool in Go

concurrency goroutines channels
Intermediate 7 steps
rust
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
 

A worker thread driven by Rust channels

concurrency message-passing channels
Intermediate 8 steps