Back to godoc.org
github.com/dropbox/godropbox/cinterop

package cinterop

v0.0.0 (52ad444)
Latest Go to latest
Published: Feb 28, 2020 | License: BSD-3-Clause | Module: github.com/dropbox/godropbox

Overview

The maximally_batched_work.go class waits until at least batch_size of an input is full and delivers it all at once to the callee, so that the callee is guaranteed to operate on a batch at a time. This is useful for batching up large database operations where small batches could lead to inefficiency. example_batched.go shows how this can be utilized. example_batched.c verifies that even if the buffer is flushed every 2 bytes, a full batch of (in this case) 8 bytes is required to invoke the function unless a full work item of zeros or the end of batch are detected. Thus, in summary the caller waits to fill up the full batch unless an error is encountered or workSize zeros in a row are discovered, aligned with WorkSize, causing a flush

Index

Constants

const Header = "58000000" + "0100" + "60c1" + "00000000" + "0000000\n"

header structure 58000000 <-- 88 bytes past this hex encoded size; 0100 major version 1 minor 0; 60c1 magic num 00000000 reserved 000000\n reserved

func ProcessBatchedData

func ProcessBatchedData(socketRead io.ReadCloser, socketWrite io.Writer,
	makeProcessBatch func() (func([]byte) []byte, func([]byte, []byte)),
	batchSize int, workItemSize int)

this function takes data from socketRead and calls processBatch on a batch of it at a time then the resulting bytes are written to wocketWrite as fast as possible

func ProcessBufferedData

func ProcessBufferedData(
	socketRead io.ReadCloser,
	socketWrite io.Writer,

	makeProcessBatch func() (
		func(input []byte) []byte,
		func(lastInput []byte, lastOutput []byte)),
	batchSize int,
	workItemSize int)

this function takes data from socketRead and calls processBatch on a batch of it at a time then the resulting bytes are written to wocketWrite as fast as possible

func StartServer

func StartServer(process func(io.ReadCloser, io.Writer))
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier