Skip to content

Commit

Permalink
RxPortal (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelquigley committed Aug 26, 2021
1 parent 859a668 commit 179b617
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
4 changes: 4 additions & 0 deletions algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type TxProfile struct {
SendKeepalive bool
ConnectionTimeout time.Duration
MaxTreeSize int
ReadsQueueSize int
PoolBufferSize int
}

func DefaultTxProfile() *TxProfile {
Expand All @@ -67,5 +69,7 @@ func DefaultTxProfile() *TxProfile {
SendKeepalive: true,
ConnectionTimeout: 15000,
MaxTreeSize: 64 * 1024,
ReadsQueueSize: 1024,
PoolBufferSize: 64 * 1024,
}
}
54 changes: 54 additions & 0 deletions rxportal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package dilithium

import (
"bytes"
"github.com/emirpasic/gods/trees/btree"
"github.com/emirpasic/gods/utils"
"github.com/openziti/dilithium/util"
"sync"
)

type RxPortal struct {
transport Transport
tree *btree.Tree
accepted int32
rxs chan *WireMessage
reads chan *RxRead
readBuffer *bytes.Buffer
rxPortalSize int
readPool *sync.Pool
ackPool *Pool
txp *TxPortal
seq *util.Sequence
closer *Closer
}

type RxRead struct {
Buf []byte
Size int
Eof bool
}

func NewRxPortal(transport Transport, txp *TxPortal, seq *util.Sequence, closer *Closer) *RxPortal {
rxp := &RxPortal{
transport: transport,
tree: btree.NewWith(txp.alg.Profile().MaxTreeSize, utils.Int32Comparator),
accepted: -1,
rxs: make(chan *WireMessage),
reads: make(chan *RxRead, txp.alg.Profile().ReadsQueueSize),
readBuffer: new(bytes.Buffer),
readPool: new(sync.Pool),
ackPool: NewPool("ackPool", uint32(txp.alg.Profile().PoolBufferSize)),
txp: txp,
seq: seq,
closer: closer,
}
rxp.readPool.New = func() interface{} {
return make([]byte, txp.alg.Profile().PoolBufferSize)
}
go rxp.run()
return rxp
}

func (rxp *RxPortal) run() {
}

0 comments on commit 179b617

Please sign in to comment.