Skip to content

Finite yielding in side effecting source #1493

Description

@cheerio-pixel

I don't know if is the right way of using pipes, but I have this pipe

    public static PipeT<Socket, Slice<byte>, M, Unit> receive(int bufferLength) =>
        from client in PipeT.awaiting<M, Socket, Slice<byte>>()
        from _ in PipeT.yieldRepeatIO<M, Socket, Slice<byte>>(
                    IO.liftAsync(async () =>
                        {
                            var buffer = new byte[bufferLength];
                            var length = await client.ReceiveAsync(buffer);
                            return new Slice<byte>(length, 0, buffer);
                        })
                )
        select unit;

So basically I want to stop yielding when the Slice has lenght zero (since that means that the client closed on us) but I don't see anything exposed publicly that allows me to fulfill this use case and I have checked the source code and see that I could use SourceT but to me looks like is not going to dispose of action of IO and is going to keep producing empty slices just that they aren't going to be pushed downstream. In this case what would be the best thing to do or is this just forcing pipes to do something is not supposed to do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions