In this article I’ll tell you about my pure functional library for Software Transactional Memory (STM) that I’ve built in C++. I adopted some advanced functional programming concepts that make it composable and convenient to use. Its implementation is rather small and robust, which differentiates the library from competitors. Let’s discuss what STM is and how to use it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Minmal Cocoa Window with Metal API | |
| No error handling intentionally to just show the happy path | |
| IMPORTANT: you odin version needs to be using the commit edcd335 or later! | |
| Otherwise you will get a silent error at runtime as Cocoa would have not been linked! | |
| */ | |
| package minimal_metal_window | |
| import NS "vendor:darwin/Foundation" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .global _main | |
| .align 2 | |
| .data | |
| msg: .ascii "Hello, World!\n" ; non-null terminated 'string' | |
| len = . - msg ; Calculate string length (14 bytes) | |
| .text | |
| _main: | |
| mov x0, #1 ; File descriptor 1 = stdout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: v1 | |
| kind: ConfigMap | |
| metadata: | |
| name: otel-collector-config | |
| data: | |
| config.yaml: | | |
| receivers: | |
| otlp: | |
| protocols: | |
| http: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Parallel bitonic sort using CUDA. | |
| * Compile with | |
| * nvcc -arch=sm_11 bitonic_sort.cu | |
| * Based on http://www.tools-of-computing.com/tc/CS/Sorts/bitonic_sort.htm | |
| * License: BSD 3 | |
| */ | |
| #include <stdlib.h> | |
| #include <stdio.h> |
Logging functionality that supports:
- If a log message should be printed is determined at comptime, meaning zero overhead for unprinted messages (so just leave the code peppered with debug logs, but when it makes sense scope them; so downstream users can filter them out)
- Scoped log messages
- Different log levels per scope
- Overrideable log output (write to file, database, etc.)
- All the standard
std.fmtformatting magic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub fn SlabAllocation(comptime types: []const type) type { | |
| var alignment: usize = 1; | |
| var slices: [types.len]type = undefined; | |
| for (types, 0..) |T, i| { | |
| slices[i] = []T; | |
| alignment = @max(alignment, @alignOf(T)); | |
| } | |
| const out_alignment = alignment; | |
| const Slices = std.meta.Tuple(&slices); | |
| return struct { |