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