godropbox: github.com/dropbox/godropbox/cinterop Index | Files | Directories

package cinterop

import "github.com/dropbox/godropbox/cinterop"

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

Package Files

buffered_work.go doc.go maximally_batched_work.go server.go

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 Uses

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 Uses

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 Uses

func StartServer(process func(io.ReadCloser, io.Writer))

Directories

PathSynopsis
libThis software package is designed to help interop between legacy C programs and go programs.
test
test/batched
test/buffered
test/unbuffered

Package cinterop imports 9 packages (graph) and is imported by 68 packages. Updated 2016-07-31. Refresh now. Tools for package owners.