safejob

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 3 Imported by: 0

Documentation

Overview

Package safejob provides functions to call job in a concurrent-safe manner.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrentJob

type ConcurrentJob struct {
	// contains filtered or unexported fields
}

ConcurrentJob executes the job concurrently.

func (*ConcurrentJob) Begin

func (j *ConcurrentJob) Begin() bool

Begin sets the start entry of the job.

func (*ConcurrentJob) Close

func (j *ConcurrentJob) Close()

Close closes the job, after closed the job can't be called anymore.

func (*ConcurrentJob) Closed

func (j *ConcurrentJob) Closed() bool

Closed returns whether the job is closed.

func (*ConcurrentJob) End

func (j *ConcurrentJob) End()

End sets the end entry of the job.

type ExclusiveBlockJob

type ExclusiveBlockJob struct {
	// contains filtered or unexported fields
}

ExclusiveBlockJob executes the job exclusively, waiting for acquiring the job control.

func (*ExclusiveBlockJob) Begin

func (j *ExclusiveBlockJob) Begin() bool

Begin sets the start entry of the job to make sure it's concurrent-safe.

func (*ExclusiveBlockJob) Close

func (j *ExclusiveBlockJob) Close()

Close the job, after closed the job can't be called anymore.

func (*ExclusiveBlockJob) Closed

func (j *ExclusiveBlockJob) Closed() bool

Closed returns whether the job is closed.

func (*ExclusiveBlockJob) End

func (j *ExclusiveBlockJob) End()

End sets the end entry of the job to make sure it's concurrent-safe.

type ExclusiveUnblockJob

type ExclusiveUnblockJob struct {
	// contains filtered or unexported fields
}

ExclusiveUnblockJob executes job exclusively, if control is not acquired, directly return.

func (*ExclusiveUnblockJob) Begin

func (j *ExclusiveUnblockJob) Begin() bool

Begin sets the start entry of the job.

func (*ExclusiveUnblockJob) Close

func (j *ExclusiveUnblockJob) Close()

Close the job, after closed the job can't be executed anymore.

func (*ExclusiveUnblockJob) Closed

func (j *ExclusiveUnblockJob) Closed() bool

Closed returns whether the job is closed.

func (*ExclusiveUnblockJob) End

func (j *ExclusiveUnblockJob) End()

End sets the end entry of the job.

type Job

type Job interface {
	// Begin sets the start entry of the job.
	Begin() bool

	// End sets the end entry of the job.
	End()

	// Close closes the job. After closed, the job can't be executed anymore.
	Close()

	// Closed returns whether the job is closed.
	Closed() bool
}

Job defines the interface that can call job multiple times and ensure concurrent safety.

type OnceJob

type OnceJob struct {
	// contains filtered or unexported fields
}

OnceJob means that the job can only be executed once and then marked closed.

func (*OnceJob) Begin

func (j *OnceJob) Begin() bool

Begin sets the start entry of the job to make sure it's concurrent-safe.

func (*OnceJob) Close

func (j *OnceJob) Close()

Close closes the job. After closed, the job can't be called anymore.

func (*OnceJob) Closed

func (j *OnceJob) Closed() bool

Closed returns whether the job is closed.

func (*OnceJob) End

func (j *OnceJob) End()

End sets the end entry of the job to make sure it's concurrent-safe.

Jump to

Keyboard shortcuts

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