cmodule

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: BSL-1.0 Imports: 4 Imported by: 0

README

cmodule

Go Reference Go Report Card

About

Package cmodule provides C batch processing. It is published on https://codeberg.org/vbsw/go-lib.

Copyright 2026, Vitali Baumtrok (vbsw@mailbox.org).

cmodule is distributed under the Boost Software License, version 1.0. (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)

cmodule is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Boost Software License for more details.

Compile

This package needs Cgo to compile and Cgo needs a C compiler.

Linux
For Cgo install GCC, or configure another compiler like clang (see https://stackoverflow.com/questions/44856124/can-i-change-default-compiler-used-by-cgo).

Windows
For Cgo install tdm-gcc (https://jmeubank.github.io/tdm-gcc/), or some other Go ABI compatible compiler like MinGW-w64.

References

Documentation

Overview

Package cmodule provides C batch processing.

Index

Constants

View Source
const (
	SequenceChunks = 4
	MaxSequenceLen = min(uint64(C.SIZE_MAX)/SequenceChunks, uint64(maxInt/SequenceChunks))
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	ModuleErr int64
	SystemErr int64
	Info      string
	Index     int
}

Error is returned by Process.

func (*Error) GoError

func (errRun *Error) GoError(modules []Module) error

GoError converts cmodule's Error to Go error and returns it.

type Module

type Module interface {
	// CProcessor returns pointer to a C function and C data.
	CProcessor(seqenceType SequenceType) (unsafe.Pointer, unsafe.Pointer)
	CToGoError(moduleErr, systemErr int64, info string) error
	SetCData(data unsafe.Pointer)
}

Module provides abstraction to C functions and data.

type Sequence

type Sequence []unsafe.Pointer

Sequence is a buffer allocated in C. It holds pointers to functions and data.

func NewSequence

func NewSequence(length int) Sequence

NewSequence returns a new instance of Sequence. Memory in C is allocated.

func (Sequence) Disable

func (seq Sequence) Disable(indices ...int)

Disable sets functions to be skipped in Process. Applies to all when indices empty.

func (Sequence) Len

func (seq Sequence) Len() int

Len returns the number of modules in the Sequence.

func (Sequence) Process

func (seq Sequence) Process(passes int) *Error

Process processes C data in batch.

func (Sequence) ProcessDestroy

func (seq Sequence) ProcessDestroy(modules []Module, passes int) error

ProcessDestroy is abbreviation for Set(Destroy), Process(passes), Sync(modules) and GoError(modules)

func (Sequence) ProcessInit

func (seq Sequence) ProcessInit(modules []Module, passes int) error

ProcessInit is abbreviation for Set(Init), Process(passes), Sync(modules) and GoError(modules)

func (Sequence) ProcessRun

func (seq Sequence) ProcessRun(modules []Module, passes int) error

ProcessRun is abbreviation for Set(Run), Process(passes), Sync(modules) and GoError(modules)

func (Sequence) Release

func (seq Sequence) Release() Sequence

Release releases C memory. Returns always nil.

func (Sequence) Remove

func (seq Sequence) Remove(indices ...int) Sequence

Remove removes elements from Sequence. Indices must be in ascending order, in interval [0,seq.Len()) and must not remove everything.

func (Sequence) Set

func (seq Sequence) Set(seqenceType SequenceType, modules []Module, indices ...int)

Set sets functions and data for Process. Applies to all when indices empty.

func (Sequence) Sync

func (seq Sequence) Sync(modules []Module, indices ...int)

Sync writes C data to modules. Applies to all when indices empty.

type SequenceType

type SequenceType int

SequenceType represents processing type.

const (
	Init SequenceType = iota
	Run
	Destroy
)

Jump to

Keyboard shortcuts

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