FoundatioFx / Foundatio

Pluggable foundation blocks for building distributed apps.
Apache License 2.0
1.99k stars 244 forks source link

locks in async context #293

Closed garcipat closed 1 year ago

garcipat commented 1 year ago

I discovered that in the file storage a lock object is used but the methods are actually asynchroneous.

Would it make sense to switch to a semaphore slim there instead? see here https://github.com/FoundatioFx/Foundatio/blob/871be38c6b4b0ab19e86041f1f8714557428fbf8/src/Foundatio/Storage/FolderFileStorage.cs#L15

niemyjski commented 1 year ago

Nice catch, we have an async lock we can use instead. Just search for AsyncLock. Would you mind submitting a pr for this?

garcipat commented 1 year ago

I will check that then. Also I'm not sure if the lock has to be added in more operations. Its only in Copy and Rename.

In the InMemoryFileStoreage also a Concurrent dictionary could be used. But I dont know if thats better becasue its less complex or if it makes it more consistent using the AsyncLock there as well.