Skip to content

Commit

Permalink
Further refactoring into TxPortal/TxAlgorithm. (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelquigley committed Aug 20, 2021
1 parent 42a4b71 commit 522242f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
44 changes: 26 additions & 18 deletions txportal.go
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
package dilithium

import (
"github.com/emirpasic/gods/trees/btree"
"sync"
)

// TxAlgorithm is an abstraction of an extensible flow-control implementation, which can be plugged into a TxPortal
// instance.
//
type TxAlgorithm interface {
Ready()
Tx(int)
Success(int)
DuplicateAck()
Retransmission(int)
}

// TxPortal manages the outgoing data transmitted by a communication instance. It is one half of a TxPortal->RxPortal
// communication pair. TxPortal is primarily concerned with optimizing the transmission rate over lossy Transport
// implementations, while ensuring reliability.
//
type TxPortal struct {
lock *sync.Mutex
tree *btree.Tree
capacity int
ready *sync.Cond
txPortalSize int
rxPortalSize int
alg TxAlgorithm
monitor *TxMonitor
closer *Closer
transport Transport
lock *sync.Mutex
transport Transport
alg TxAlgorithm
monitor *TxMonitor
closer *Closer
pool *Pool
}

// TxAlgorithm is an abstraction of an extensible flow-control implementation, which can be plugged into a TxPortal
// instance.
//
type TxAlgorithm interface {
Success()
DuplicateAck()
Retransmission()
func newTxPortal(transport Transport, alg TxAlgorithm, closer *Closer, pool *Pool) *TxPortal {
txp := &TxPortal{
lock: new(sync.Mutex),
transport: transport,
alg: alg,
closer: closer,
}
// txp.monitor =
return txp
}
10 changes: 8 additions & 2 deletions westworld.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ func NewWestworldAlgorithm(pf *WestworldProfile, txPortal *TxPortal) TxAlgorithm
return &WestworldAlgorithm{pf, txPortal}
}

func (self *WestworldAlgorithm) Success() {
func (self *WestworldAlgorithm) Ready() {
}

func (self *WestworldAlgorithm) Tx(size int) {
}

func (self *WestworldAlgorithm) Success(size int) {
}

func (self *WestworldAlgorithm) DuplicateAck() {
}

func (self *WestworldAlgorithm) Retransmission() {
func (self *WestworldAlgorithm) Retransmission(size int) {
}

type WestworldProfile struct {
Expand Down

0 comments on commit 522242f

Please sign in to comment.