Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

leptonyu/sloth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sloth

Current Version: 0.3
Continuous Integration: Build Status
License: Apache 2.0
Author: Daniel Yu
Java Version: Java 8

Use sloth with Maven

Add the following dependency to your pom.xml.

<dependency>
	<groupId>me.icymint</groupId>
	<artifactId>sloth-core</artifactId>
	<version>0.3</version>
</dependency>

Deferred utility

The Deferred object is inspired by the Golang keyword defer. It collects operations need to execute and use Deferred#close() to execute all of them.

	Deferred df=Deferred.create();
	try{
		// Here to add the DeferredOpration to df.
		// For example:
		ExecutorService pool=Executors.newSingleThreadPool();
		df.defer(pool::shutdown);
		// next, use the pool.
		pool.submit(()->System.out.println("Hello"));
	}finally{
		df.close();
	}

try-with usage:

	try(Deferred df=Deffered.create()){
		// Here to add the DeferredOpration to df.
		// For example:
		ExecutorService pool=Executors.newSingleThreadPool();
		df.defer(pool::shutdown);
		// next, use the pool.
		pool.submit(()->System.out.println("Hello"));
	}

About

Sloth

Resources

License

Unknown, Apache-2.0 licenses found

Licenses found

Unknown
LICENSE
Apache-2.0
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published