Skip to content

A checkpoint is a class and method marker, and it is used when you want a piece of code, even if executed by several independent processes, to be executed only once.

License

Notifications You must be signed in to change notification settings

wniemiec-task-java/checkpoint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Checkpoint

A checkpoint is a class and method marker, and it is used when you want a piece of code, even if executed by several independent processes, to be executed only once.

Coverage status Java compatibility Maven Central release License


❇ Introduction

If you need to know if a piece of code has already been executed by another process, then this is the perfect library for you. A checkpoint is a class and method marker, and it is used when you want a piece of code, even if executed by several independent processes, to be executed only once.

❓ How to use

  1. Add one of the options below to the pom.xml file:

Using Maven Central (recomended):

<dependency>
  <groupId>io.github.wniemiec-task-java</groupId>
  <artifactId>checkpoint</artifactId>
  <version>LATEST</version>
</dependency>

Using GitHub Packages:

<dependency>
  <groupId>wniemiec.task.java</groupId>
  <artifactId>checkpoint</artifactId>
  <version>LATEST</version>
</dependency>
  1. Run
$ mvn install
  1. Use it
[...]

import wniemiec.task.java.Checkpoint;

[...]

public class CheckpointExample {

[...]

Checkpoint checkpoint = new Checkpoint(tmpDir, "checkpoint-example");

System.out.println("Trying to access piece of code...");

if (checkpoint.isEnabled()) {
	System.out.println("Piece of code already executed");
}
else {
	System.out.println("Piece of code executed for the first time");
	checkpoint.enable();
}

System.out.println("...");

while (true) {
}

[...]
Process one

$ java CheckpointExample
Trying to access piece of code...
Piece of code executed for the first time
...
Process two

$ java CheckpointExample
Trying to access piece of code...
Piece of code already executed
...

📖 Documentation

Property Parameter type Return type Description Default parameter value
enable void void Starts a new checkpoint -
disable void void Disables checkpoint -
exists void boolean Checks if a checkpoint was created. -
isEnabled void boolean Checks if the checkpoint is active. -
delete void void Checks if the checkpoint is active. -

🚩 Changelog

Details about each version are documented in the releases section.

🤝 Contribute!

See the documentation on how you can contribute to the project here.

📁 Files

/

Name Type Description
dist Directory Released versions
docs Directory Documentation files
src Directory Source files

About

A checkpoint is a class and method marker, and it is used when you want a piece of code, even if executed by several independent processes, to be executed only once.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages