Skip to content

Conversation

@dkovba
Copy link
Contributor

@dkovba dkovba commented Jun 11, 2025

This PR ensures that we enter a lock inside the @SendableProperty implementation as soon as we access a computed property. Additionally, it mirrors the access level of the original property. Both changes are required for improved accuracy of progress updates in container. Additionally, it should resolve #60 that occurs on certain configurations.

Please tag as 0.1.1 after merging.

@dcantah
Copy link
Contributor

dcantah commented Jun 11, 2025

I don't fully understand why we need to ditch Synchronization's mutex, could you give more details?

@dkovba
Copy link
Contributor Author

dkovba commented Jun 11, 2025

Mutex has adopted sending:

func withLock<Result, E>((inout sending Value) throws(E) -> sending Result) throws(E) -> sending Result

This made it incompatible with computed variables:

macro expansion @SendableProperty:10:9: error: 'inout sending' parameter '$0' cannot be task-isolated at end of function
`- /Users/Dmitry/Apple/containerization/Sources/ContainerizationOS/Socket/Socket.swift:78:30: note: expanded code originates here
 75 |     private let _queue: DispatchQueue
 76 | 
 77 |     @SendableProperty
    |     |- note: in expansion of macro 'SendableProperty' on property '_state' here
    |     `- note: in expansion of macro 'SendableProperty' on property '_state' here
 78 |     private var _state: State
    +--- macro expansion @SendableProperty -----------------------------
    | 8 |         __state.withLock {
    | 9 |             $0 = newValue
    |10 |         }
    |   |         |- error: 'inout sending' parameter '$0' cannot be task-isolated at end of function
    |   |         `- note: task-isolated '$0' risks causing races in between task-isolated uses and caller uses since caller assumes value is not actor isolated
    |11 |     }
    |12 | }
    +-------------------------------------------------------------------
 79 | 
 80 |     public var fileDescriptor: Int32 {
[1666/1696] Compiling ContainerizationOS User.swift
make[1]: *** [all] Error 1
make: *** [vminitd] Error 2

@crosbymichael crosbymichael merged commit f245ae6 into apple:main Jun 11, 2025
2 checks passed
@dkovba dkovba deleted the progress-updates branch June 12, 2025 03:43
adityaramani pushed a commit to apple/container that referenced this pull request Jun 13, 2025
This PR resolves the problem of dropped progress updates and ensures the
accuracy of the information provided in the progress bar. Additionally,
it adds the displaying of the finished state to the progress bar.
Requires merging and tagging
apple/containerization#91.
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.

Unable to build containerization using make all

4 participants