Commit Graph

7 Commits

Author SHA1 Message Date
Cory Benfield 8423040a9b
Mildly rework the NIOLock storage (#2395)
Motivation:

NIOLock uses a storage object constructed from a ManagedBuffer. In
general this is fine, but it's a tricky API to use safely and we want to
avoid violating any of its guarantees.

Modifications:

- Store the value in the header and the lock in the elements
- Add debug assertions on alignment

Result:

We'll be a bit more confident of the use of NIOLock
2023-03-27 16:37:09 +01:00
Philip Brown 59e1f6f375
Tail allocate mutex and a generic value using ManagedBuffer (#2349)
Motivation:

Currently, NIOLock and NIOLockedValueBox incur unnecessary allocation and indirection costs.

Modifications:

Create namespace LockOperations for organization
Create LockStorage<Value>, a subclass of ManagedBuffer<LockPrimitive, Value>
Store the mutex as the header and the generic value as the first and only element
Update NIOLock and NIOLockedValueBox to use LockStorage

Result:

Optimal lock and value memory layout
Fewer allocations and less indirection
Code generation is excellent
2023-01-17 16:11:10 +00:00
David Nadoba c7b4989b02
Remove `#if compiler(>=5.5)` (#2292)
### Motivation
We only support Swift 5.5.2+.

### Modification
Remove all `#if swift(>=5.5)` conditional compilation blocks.

### Result
less branching
2022-10-13 07:17:46 -07:00
David Nadoba cdeffe8c5b
Remove wrong comment about performance (#2281) 2022-10-06 08:55:08 +01:00
toluRV dee448ac8b
Fixed compile errors on windows (#2278)
Compile error seems to be caused by https://github.com/apple/swift-nio/pull/2266/
2022-10-05 01:55:40 -07:00
Mahdi Bahrami e9eeaadf11
add `withLockVoid(_:)` to NIOLock (#2276) 2022-10-04 02:59:27 -07:00
Johannes Weiss 4ed8e1e228
rename class Lock to struct NIOLock (#2266) 2022-09-21 07:36:42 -07:00