Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: java
jdk: oraclejdk8
install:
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
before_install:
- chmod +x buildscript
script: ./buildscript
os: linux
10 changes: 9 additions & 1 deletion buildscript
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
mvn test -B
rootdir=$(pwd)
for dir in $(find . -maxdepth 1 -type d); do
if [ "$dir" != "." ] && [ "$dir" != "./.git" ]; then
cd $dir
mvn test -B
cd $rootdir
fi
done

16 changes: 16 additions & 0 deletions hw1pool/.idea/checkstyle-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions hw1pool/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions hw1pool/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions hw1pool/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions hw1pool/.idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions hw1pool/hw1pool.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.9" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.github.stefanbirkner:system-rules:1.16.0" level="project" />
<orderEntry type="library" name="Maven: com.intellij:annotations:12.0" level="project" />
</component>
</module>
40 changes: 40 additions & 0 deletions hw1pool/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>ru.spbau.group202.sharkova</groupId>
<artifactId>hw1pool</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>1.16.0</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.intellij/annotations -->
<dependency>
<groupId>com.intellij</groupId>
<artifactId>annotations</artifactId>
<version>12.0</version>
</dependency>
</dependencies>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ru.spbau.group202.sharkova.hw1pool;

/**
* This exception is thrown by LightFuture get() method
* whenever an exception occurred during supplier get() method execution.
*/
public class LightExecutionException extends Exception {
LightExecutionException(Exception e) {
super(e);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package ru.spbau.group202.sharkova.hw1pool;

import java.util.function.Function;

/**
* This interface represents a task for a thread pool.
* Available methods: check if the task is completed,
* get task result, chain the execution result to another task.
* @param <T> task execution result type parameter
* */
public interface LightFuture<T> {
/**
* Indicates the state of the task.
* @return true if the task is completed.
*/
boolean isReady();

/**
* Returns task execution result;
* if not completed, waits until the execution is finished.
* @throws LightExecutionException if the corresponding supplier
* throws an exception.
* */
T get() throws LightExecutionException;

/**
* Takes current task result and applies a given Function object
* to it, creating a new task.
* @param function the task that uses the current task result
* @return a new task
* */
LightFuture<T> thenApply(Function<T, T> function);
}
Loading