guillermomuntaner / Burritos

A collection of Swift Property Wrappers (formerly "Property Delegates")
MIT License
1.33k stars 43 forks source link

Async write to prevent blocking of the calling thread #5

Closed okla closed 5 years ago

okla commented 5 years ago

Reads are still concurrent (from different threads), but writes won't block the calling thread.

guillermomuntaner commented 5 years ago

Hello @okla; thanks for contributing.

The project is not compiling; some more work is needed since using sync requires explicit capture semantics.

I kept the mutate method synchronous for consistency with read/write access and I would like to keep it like that, but I am really open to add a second mutateAsync method.

Would you mind pushing those changes?

guillermomuntaner commented 5 years ago

Hey again.

Using async requires an escaping closure. Since the wrapper is a struct we cannot reference itself because it is a value type. I might consider switching to classes if this becomes an important/requested feature, but for now I think this is not needed, hence i am closing the PR.

Thanks anyways for the idea! Regards.