Skip to content

Commit

Permalink
[mem]: Document mutex, rollback stack and tracking allocators
Browse files Browse the repository at this point in the history
  • Loading branch information
flysand7 committed Sep 13, 2024
1 parent 3ed2ab6 commit 016d1a8
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 113 deletions.
15 changes: 15 additions & 0 deletions core/mem/mutex_allocator.odin
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,31 @@ package mem

import "core:sync"

/*
The data for mutex allocator.
*/
Mutex_Allocator :: struct {
backing: Allocator,
mutex: sync.Mutex,
}

/*
Initialize the mutex allocator.
This procedure initializes the mutex allocator using `backin_allocator` as the
allocator that will be used to pass all allocation requests through.
*/
mutex_allocator_init :: proc(m: ^Mutex_Allocator, backing_allocator: Allocator) {
m.backing = backing_allocator
m.mutex = {}
}

/*
Mutex allocator.
The mutex allocator is a wrapper for allocators that is used to serialize all
allocator requests across multiple threads.
*/
@(require_results)
mutex_allocator :: proc(m: ^Mutex_Allocator) -> Allocator {
return Allocator{
Expand Down
46 changes: 30 additions & 16 deletions core/mem/raw.odin
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,82 @@ import "base:builtin"
import "base:runtime"

/*
Mamory layout of the `any` type.
Memory layout of the `any` type.
*/
Raw_Any :: runtime.Raw_Any

/*
Mamory layout of the `string` type.
Memory layout of the `string` type.
*/
Raw_String :: runtime.Raw_String

/*
Mamory layout of the `cstring` type.
Memory layout of the `cstring` type.
*/
Raw_Cstring :: runtime.Raw_Cstring

/*
Mamory layout of `[]T` types.
Memory layout of `[]T` types.
*/
Raw_Slice :: runtime.Raw_Slice

/*
Mamory layout of `[dynamic]T` types.
Memory layout of `[dynamic]T` types.
*/
Raw_Dynamic_Array :: runtime.Raw_Dynamic_Array

/*
Mamory layout of `map[K]V` types.
Memory layout of `map[K]V` types.
*/
Raw_Map :: runtime.Raw_Map

/*
Mamory layout of `#soa []T` types.
Memory layout of `#soa []T` types.
*/
Raw_Soa_Pointer :: runtime.Raw_Soa_Pointer

/*
Mamory layout of the `complex32` type.
Memory layout of the `complex32` type.
*/
Raw_Complex32 :: runtime.Raw_Complex32

/*
Mamory layout of the `complex64` type.
Memory layout of the `complex64` type.
*/
Raw_Complex64 :: runtime.Raw_Complex64

/*
Mamory layout of the `complex128` type.
Memory layout of the `complex128` type.
*/
Raw_Complex128 :: runtime.Raw_Complex128

/*
Mamory layout of the `quaternion64` type.
Memory layout of the `quaternion64` type.
*/
Raw_Quaternion64 :: runtime.Raw_Quaternion64

/*
Mamory layout of the `quaternion128` type.
Memory layout of the `quaternion128` type.
*/
Raw_Quaternion128 :: runtime.Raw_Quaternion128

/*
Mamory layout of the `quaternion256` type.
Memory layout of the `quaternion256` type.
*/
Raw_Quaternion256 :: runtime.Raw_Quaternion256

/*
Mamory layout of the `quaternion64` type.
Memory layout of the `quaternion64` type.
*/
Raw_Quaternion64_Vector_Scalar :: runtime.Raw_Quaternion64_Vector_Scalar

/*
Mamory layout of the `quaternion128` type.
Memory layout of the `quaternion128` type.
*/
Raw_Quaternion128_Vector_Scalar :: runtime.Raw_Quaternion128_Vector_Scalar

/*
Mamory layout of the `quaternion256` type.
Memory layout of the `quaternion256` type.
*/
Raw_Quaternion256_Vector_Scalar :: runtime.Raw_Quaternion256_Vector_Scalar

Expand Down
Loading

0 comments on commit 016d1a8

Please sign in to comment.