write in batches

This commit is contained in:
Jay Wren
2025-11-11 15:06:45 -05:00
parent 0f9b33aa36
commit b2bc6a09ca
6 changed files with 286 additions and 10 deletions

View File

@@ -55,3 +55,41 @@ func (u *StdConn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte) {
return msgs, buffers, names
}
func (u *StdConn) PrepareWriteMessages4(n int) ([]rawMessage, []iovec, [][]byte) {
msgs := make([]rawMessage, n)
iovecs := make([]iovec, n)
names := make([][]byte, n)
for i := range msgs {
names[i] = make([]byte, unix.SizeofSockaddrInet4)
// Point to the iovec in the slice
msgs[i].Hdr.Iov = &iovecs[i]
msgs[i].Hdr.Iovlen = 1
msgs[i].Hdr.Name = &names[i][0]
msgs[i].Hdr.Namelen = unix.SizeofSockaddrInet4
}
return msgs, iovecs, names
}
func (u *StdConn) PrepareWriteMessages6(n int) ([]rawMessage, []iovec, [][]byte) {
msgs := make([]rawMessage, n)
iovecs := make([]iovec, n)
names := make([][]byte, n)
for i := range msgs {
names[i] = make([]byte, unix.SizeofSockaddrInet6)
// Point to the iovec in the slice
msgs[i].Hdr.Iov = &iovecs[i]
msgs[i].Hdr.Iovlen = 1
msgs[i].Hdr.Name = &names[i][0]
msgs[i].Hdr.Namelen = unix.SizeofSockaddrInet6
}
return msgs, iovecs, names
}