Skip to content

Conversation

@abelbraaksma
Copy link
Member

@abelbraaksma abelbraaksma commented Nov 7, 2022

This implements the following, in line with Seq.except. I'm considering adding a TaskSeq.remove, as it'd be a much lighter implementation and users may not always need set-except operation style.

This adds:

module TaskSeq =
    val except<'T when 'T: equality> : itemsToExclude: taskSeq<'T> -> source: taskSeq<'T> -> taskSeq<'T>
    val exceptOfSeq<'T when 'T: equality> : itemsToExclude: seq<'T> -> source: taskSeq<'T> -> taskSeq<'T>

@dsyme I'm not 100% sure this r/w lock approach is ideal (as I have to use it synchronously), I'm considering either a semaphore or adding an F# version of Stephen Cleary's AsyncReaderWriterLock (itself based on Stephen Toub's) implementation, which may be useful to expose as well somehow.

A similar comment about using a r/w lock was mentioned in some spots in AsyncSeq.

https://github.com/StephenCleary/AsyncEx/blob/8a73d0467d40ca41f9f9cf827c7a35702243abb8/src/Nito.AsyncEx.Coordination/AsyncReaderWriterLock.cs#L16

@abelbraaksma abelbraaksma requested a review from dsyme November 7, 2022 02:27
@abelbraaksma abelbraaksma force-pushed the add-append-delay-except-insert branch 2 times, most recently from 8dab14b to d510f41 Compare November 7, 2022 10:42
@abelbraaksma abelbraaksma force-pushed the add-append-delay-except-insert branch from d510f41 to e0b31ea Compare November 7, 2022 10:46
@abelbraaksma
Copy link
Member Author

I asked around about this approach. Some people recommended removing the try/finally as hashSet.Add doesn't raise. This is probably correct, but until I know more, I'll leave that in, as entering a protected region is quite cheap in .NET.

@abelbraaksma abelbraaksma merged commit 6ee16b8 into main Nov 9, 2022
@abelbraaksma abelbraaksma deleted the add-append-delay-except-insert branch November 9, 2022 12:54
@abelbraaksma abelbraaksma self-assigned this Nov 25, 2022
@abelbraaksma abelbraaksma added enhancement New feature or request topic: surface area Adds functions to the public surface area labels Nov 25, 2022
@abelbraaksma abelbraaksma added this to the v0.2.1 milestone Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request topic: surface area Adds functions to the public surface area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants