-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further refactoring into TxPortal/TxAlgorithm. (#132)
- Loading branch information
1 parent
42a4b71
commit 522242f
Showing
2 changed files
with
34 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters