Skip to content

raj200501/swift-corelibs-multitasking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

90 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Swift Corelibs Multitasking

πŸš€ The Ultimate Concurrency and Parallelism Library for Swift

Overview

Welcome to swift-corelibs-multitasking – the state-of-the-art library engineered to transform concurrency and parallelism in Apple's ecosystem. Leveraging the power of Grand Central Dispatch (GCD), this library brings advanced scheduling algorithms, superior thread management, and seamless integration with Swift’s async/await features to deliver unmatched performance and efficiency in multitasking operations.

Key Features

🌟 Advanced Scheduling Algorithms

  • FairScheduler: Ensures equal execution opportunities for all tasks, preventing any single task from monopolizing resources.
  • PriorityScheduler: Executes tasks based on assigned priority levels, allowing critical tasks to be processed first.
  • DeadlineScheduler: Schedules tasks according to their deadlines, ensuring time-sensitive tasks are completed on time.
  • LoadBalancer: Dynamically distributes tasks across available resources for optimal performance and efficiency.

⚑ Superior Thread Management

  • Thread Pooling: Efficiently manages thread creation and reuse to minimize overhead and improve performance.
  • Thread Prioritization: Assigns priorities to threads to ensure that critical tasks get the resources they need.
  • Real-time Monitoring: Continuously tracks thread performance and resource utilization to adapt to changing workloads.

πŸ”— Seamless Swift Integration

  • Async/Await Support: Full integration with Swift's async/await syntax for modern, asynchronous programming.
  • Combine Framework Integration: Leverages the power of Combine to handle complex task coordination and data flow.
  • Cross-Platform Compatibility: Supports macOS, iOS, tvOS, watchOS, and Linux, providing a consistent multitasking solution across platforms.

πŸ“Š Comprehensive Performance Monitoring

  • Real-time Metrics: Tracks performance metrics in real-time to identify bottlenecks and optimize task execution.
  • Detailed Logging: Provides extensive logs of task execution and system performance for debugging and analysis.
  • Customizable Alerts: Configures alerts for specific performance thresholds to proactively address potential issues.

Getting Started

Prerequisites

  • Xcode 12.5 or later
  • Swift 5.5 or later

Installation

git clone https://github.com/apple/swift-corelibs-multitasking.git
cd swift-corelibs-multitasking
swift build

Installation

import Multitasking

let task = Task(name: "Sample Task") {
    // Perform task
    print("Task is running")
}

let scheduler = TaskScheduler()
scheduler.addTask(task)
scheduler.run()

Examples

Explore the examples directory for various use cases and advanced scenarios demonstrating the power and flexibility of swift-corelibs-multitasking.

License

This project is licensed under the Apache License, Version 2.0. See LICENSE for more details.

βœ… Verified Quickstart

The following steps were executed on a clean checkout in this environment:

swift build
swift test
swift run multitasking-demo

Troubleshooting

  • If swift build reports Package.swift missing, ensure you're running the commands from the repository root after pulling the latest changes.
  • On Linux environments without Apple's Combine framework, the package falls back to an included lightweight Combine shim so no extra dependencies are required.
  • If tests hang around threading, re-run with swift test --disable-sandbox to ensure threads can be created freely in restricted environments.

Quickstart (60 seconds)

swift build
swift test
swift run multitasking-demo

Demo

swift run multitasking-demo --demo

Verification

./scripts/verify.sh

Project structure

  • Sources/Multitasking: Core library implementation.
  • Sources/multitasking-demo: Demo CLI executable.
  • tests/core: XCTest suite for core functionality and observability utilities.
  • docs: Architecture, demo, security, and baseline notes.
  • scripts: Developer tools (verify, lint, doctor).

Design decisions

  • Additive enhancements are opt-in to avoid changing default behavior.
  • Observability utilities run in-process and do not require external services.
  • Demo mode uses a temporary directory and avoids network access.

About

Enhances multitasking capabilities across Apple's ecosystem, focusing on improved concurrency and parallelism for macOS, iOS, and other Apple platforms. This library extends Grand Central Dispatch (GCD) with advanced scheduling algorithms, enhanced thread management, and seamless integration with Swift's async/await features. @apple

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors