cinterop

package
v0.0.0-...-436d200 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2023 License: BSD-3-Clause Imports: 9 Imported by: 76

Documentation

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

View Source
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

Variables

This section is empty.

Functions

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))

Types

This section is empty.

Directories

Path Synopsis
This software package is designed to help interop between legacy C programs and go programs.
This software package is designed to help interop between legacy C programs and go programs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL