github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/actor/unbounded_priority.go (about)

     1  package actor
     2  
     3  import (
     4  	"github.com/asynkron/protoactor-go/internal/queue/goring"
     5  	"github.com/asynkron/protoactor-go/internal/queue/mpsc"
     6  )
     7  
     8  func NewPriorityGoringQueue() *priorityQueue {
     9  	return NewPriorityQueue(func() queue {
    10  		return &unboundedMailboxQueue{
    11  			userMailbox: goring.New(10),
    12  		}
    13  	})
    14  }
    15  
    16  //goland:noinspection ALL
    17  func UnboundedPriority(mailboxStats ...MailboxMiddleware) MailboxProducer {
    18  	return func() Mailbox {
    19  		return &defaultMailbox{
    20  			systemMailbox: mpsc.New(),
    21  			userMailbox:   NewPriorityGoringQueue(),
    22  			middlewares:   mailboxStats,
    23  		}
    24  	}
    25  }
    26  
    27  func NewPriorityMpscQueue() *priorityQueue {
    28  	return NewPriorityQueue(func() queue {
    29  		return mpsc.New()
    30  	})
    31  }
    32  
    33  func UnboundedPriorityMpsc(mailboxStats ...MailboxMiddleware) MailboxProducer {
    34  	return func() Mailbox {
    35  		return &defaultMailbox{
    36  			systemMailbox: mpsc.New(),
    37  			userMailbox:   NewPriorityMpscQueue(),
    38  			middlewares:   mailboxStats,
    39  		}
    40  	}
    41  }