Documentation

Lapis.Concurrent.Channel

An atomic counter for generating unique IDs

Instances For

    Create a new counter starting at 0

    Equations
    Instances For

      Create a new counter starting at a given value

      Equations
      Instances For

        Atomically increment and return the previous value

        Equations
        Instances For

          Get the current value without incrementing

          Equations
          Instances For

            Unbounded Channel #

            An unbounded MPSC (multi-producer, single-consumer) channel. Multiple actors can send messages, one actor receives them in order. Uses atomic IO.Ref operations - no mutex needed.

            Instances For

              Create a new unbounded channel

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Send a message to the channel (non-blocking). Uses atomic modify - safe for concurrent sends.

                Equations
                Instances For
                  partial def Lapis.Concurrent.Channel.Unbounded.recv {α : Type} (ch : Unbounded α) :
                  IO α

                  Receive a message from the channel (blocking)

                  Try to receive a message without blocking

                  Equations
                  Instances For

                    Check if the channel has pending messages

                    Equations
                    Instances For

                      Get the number of pending messages

                      Equations
                      Instances For

                        Bounded Channel #

                        A bounded MPSC channel with backpressure. Senders block when the channel is full. Uses atomic IO.Ref operations - no mutex needed.

                        Instances For

                          Create a new bounded channel with given capacity

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            partial def Lapis.Concurrent.Channel.Bounded.send {α : Type} (ch : Bounded α) (msg : α) :

                            Send a message to the channel (blocks if full)

                            Try to send a message without blocking

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              partial def Lapis.Concurrent.Channel.Bounded.recv {α : Type} (ch : Bounded α) :
                              IO α

                              Receive a message from the channel (blocking)

                              Try to receive a message without blocking

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                Check if the channel is full

                                Equations
                                Instances For

                                  Check if the channel is empty

                                  Equations
                                  Instances For

                                    Oneshot Channel #

                                    A oneshot channel for single request-response patterns. Can only be used once: one send, one receive.

                                    Instances For

                                      Create a new oneshot channel

                                      Equations
                                      Instances For
                                        def Lapis.Concurrent.Channel.Oneshot.send {α : Type} (ch : Oneshot α) (value : α) :

                                        Send a value (can only be called once)

                                        Equations
                                        Instances For

                                          Receive the value (blocks until sent)

                                          Equations
                                          Instances For

                                            Try to receive without blocking (returns none if not yet resolved)

                                            Equations
                                            Instances For

                                              Check if the value has been sent

                                              Equations
                                              Instances For

                                                Select (Multi-channel waiting) #

                                                Result of a select operation

                                                Instances For