Skip to content

Conversation

@muukii
Copy link
Contributor

@muukii muukii commented Sep 20, 2025

Summary

  • Converted TaskManagerActor from actor to final class with manual synchronization for better performance
  • Renamed TaskManagerActor to TaskManager for simplicity
  • Renamed SwiftUI property wrapper from TaskManager to LocalTask to avoid naming conflicts
  • Removed LocalTaskWrapper, exposing TaskManager directly from the property wrapper

Changes

Core Refactoring

  • TaskNode: Converted from class to struct with OSAllocatedUnfairLock for thread-safe state management
  • TaskManager (formerly TaskManagerActor): Converted from actor to class with Sendable conformance
    • Uses OSAllocatedUnfairLock for manual synchronization
    • Removed actor overhead for better performance
    • Removed batch methods as they're no longer needed

File Organization

  • Extracted TaskNode into separate file (TaskNode.swift)
  • Extracted AutoReleaseContinuationBox into separate file (AutoReleaseContinuationBox.swift)

SwiftUI Integration

  • Renamed @taskmanager property wrapper to @localtask
  • Removed LocalTaskWrapper intermediate layer
  • Direct exposure of TaskManager instance from property wrapper
  • Simplified API surface

Test Results

All tests passing ✅

Breaking Changes

  • TaskManagerActor renamed to TaskManager
  • SwiftUI property wrapper renamed from @TaskManager to @LocalTask
  • Batch methods removed

🤖 Generated with Claude Code

muukii and others added 10 commits September 21, 2025 00:12
… files

- Extract TaskNode class from TaskQueueActor.swift to TaskNode.swift
- Extract AutoReleaseContinuationBox class from TaskQueueActor.swift to AutoReleaseContinuationBox.swift
- Improve code organization and maintainability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Major architectural improvements:
- Convert TaskManagerActor from actor to class with manual synchronization using OSAllocatedUnfairLock
- Convert TaskNode from class to struct with internal state management
- Remove batch methods from TaskManagerActor (no longer needed)
- Remove async from cancel methods (not needed with class-based implementation)
- Remove TaskQueueActor and TaskStackActor (consolidated into TaskManagerActor)

Key changes:
- TaskNode is now a value type (struct) with internal State managed by OSAllocatedUnfairLock
- TaskManagerActor uses OSAllocatedUnfairLock for thread-safe state management
- All tests updated to work with the new implementation
- Added Swift Testing framework tests alongside XCTest

Benefits:
- Reduced actor overhead for better performance
- More granular control over synchronization
- Simplified API with batch methods removed
- Maintains thread safety with manual locking

All tests passing ✅

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Renamed TaskManagerActor class to TaskManager for simplicity
- Renamed TaskManagerActor.swift file to TaskManager.swift
- Renamed SwiftUI property wrapper from TaskManager to LocalTask to avoid naming conflicts
- Updated all test files to use new class name
- Updated README documentation with new naming conventions
- Removed references to batch operations which were already removed
- Updated all code examples to show synchronous API usage
- Remove LocalTaskWrapper and expose TaskManager directly from LocalTask property wrapper
- Add taskWithBinding extension method to TaskManager for SwiftUI binding support
- Update README documentation and examples
- Simplify the overall API surface
- TaskManager now conforms to Sendable directly without @unchecked
- Remove taskWithBinding extension that was causing issues
- Simplified SwiftUI integration
- Test queued task execution order with waitInCurrent mode
- Test task cancellation with dropCurrent mode
- Test concurrent execution with different keys
- Test cancellation propagation across queued tasks
- Test completion order guarantees with wait mode

These tests verify the internal TaskNode wait functionality through the public TaskManager API
@muukii muukii merged commit 87605b6 into main Sep 22, 2025
2 checks passed
@muukii muukii deleted the muukii/up branch September 22, 2025 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant