Documentation

Init.Data.Channel

@[deprecated "Use Std.Channel.State from Std.Sync.Channel instead" (since := "2024-12-02")]
structure IO.Channel.State (α : Type) :

Internal state of an Channel.

We maintain the invariant that at all times either consumers or values is empty.

Instances For
    Equations
    @[deprecated "Use Std.Channel from Std.Sync.Channel instead" (since := "2024-12-02")]
    def IO.Channel (α : Type) :

    FIFO channel with unbounded buffer, where recv? returns a Task.

    A channel can be closed. Once it is closed, all sends are ignored, and recv? returns none once the queue is empty.

    Equations
    Instances For
      @[deprecated "Use Std.Channel.new from Std.Sync.Channel instead" (since := "2024-12-02")]

      Creates a new Channel.

      Equations
      Instances For
        @[deprecated "Use Std.Channel.send from Std.Sync.Channel instead" (since := "2024-12-02")]
        def IO.Channel.send {α : Type} (ch : IO.Channel α) (v : α) :

        Sends a message on an Channel.

        This function does not block.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[deprecated "Use Std.Channel.close from Std.Sync.Channel instead" (since := "2024-12-02")]

          Closes an Channel.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            @[deprecated "Use Std.Channel.recv? from Std.Sync.Channel instead" (since := "2024-12-02")]
            def IO.Channel.recv? {α : Type} (ch : IO.Channel α) :

            Receives a message, without blocking. The returned task waits for the message. Every message is only received once.

            Returns none if the channel is closed and the queue is empty.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              @[deprecated "Use Std.Channel.forAsync from Std.Sync.Channel instead" (since := "2024-12-02")]
              partial def IO.Channel.forAsync {α : Type} (f : αBaseIO Unit) (ch : IO.Channel α) (prio : Task.Priority := Task.Priority.default) :

              ch.forAsync f calls f for every messages received on ch.

              Note that if this function is called twice, each forAsync only gets half the messages.

              @[deprecated "Use Std.Channel.recvAllCurrent from Std.Sync.Channel instead" (since := "2024-12-02")]

              Receives all currently queued messages from the channel.

              Those messages are dequeued and will not be returned by recv?.

              Equations
              Instances For
                @[deprecated "Use Std.Channel.Sync from Std.Sync.Channel instead" (since := "2024-12-02")]

                Type tag for synchronous (blocking) operations on a Channel.

                Equations
                Instances For
                  @[deprecated "Use Std.Channel.sync from Std.Sync.Channel instead" (since := "2024-12-02")]

                  Accesses synchronous (blocking) version of channel operations.

                  For example, ch.sync.recv? blocks until the next message, and for msg in ch.sync do ... iterates synchronously over the channel. These functions should only be used in dedicated threads.

                  Equations
                  • ch.sync = ch
                  Instances For
                    @[deprecated "Use Std.Channel.Sync.recv? from Std.Sync.Channel instead" (since := "2024-12-02")]

                    Synchronously receives a message from the channel.

                    Every message is only received once. Returns none if the channel is closed and the queue is empty.

                    Equations
                    Instances For

                      for msg in ch.sync do ... receives all messages in the channel until it is closed.

                      Equations