Skip to content

Commit 90f9e78

Browse files
committed
wip,new!: complete revision. names and structure of program items was changed
1 parent 6c82e60 commit 90f9e78

28 files changed

+1624
-1384
lines changed

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>com.github.sttk</groupId>
7+
<groupId>io.github.sttk</groupId>
88
<artifactId>sabi</artifactId>
99
<version>0.4.0</version>
1010
<packaging>jar</packaging>
@@ -47,6 +47,12 @@
4747
</properties>
4848

4949
<dependencies>
50+
<dependency>
51+
<groupId>io.github.sttk</groupId>
52+
<artifactId>errs</artifactId>
53+
<version>0.1.0</version>
54+
<scope>compile</scope>
55+
</dependency>
5056
<dependency>
5157
<groupId>org.junit.jupiter</groupId>
5258
<artifactId>junit-jupiter</artifactId>

src/main/java/com/github/sttk/sabi/AsyncGroup.java

Lines changed: 6 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,71 +4,14 @@
44
*/
55
package com.github.sttk.sabi;
66

7+
import com.github.sttk.errs.Exc;
8+
79
import java.util.Map;
810
import java.util.HashMap;
911

10-
/**
11-
* Manages multiple asynchronous runner and allows for waiting until all runners have completed.
12-
* It also handles error collection to store errors that encounter during executions.
13-
*/
14-
public class AsyncGroup {
15-
16-
/** Is a reason which indicates that a runner has failed during execution. */
17-
public record RunnerFailed() {}
18-
19-
/** Is a reason which indicates that a runner was interrupted during execution. */
20-
public record RunnerInterrupted() {}
21-
22-
/** Map to store errors associated with each asynchronous runner by name. */
23-
private Map<String, Err> errMap = new HashMap<>();
24-
25-
/** Map to store virtual threads associated with each asynchronous runner by name. */
26-
private Map<String, Thread> vthMap = new HashMap<>();
27-
28-
/** Name associated with the group of asynchronous runner. */
29-
public String name;
30-
31-
/**
32-
* Is the default constructor.
33-
*/
34-
AsyncGroup() {}
35-
36-
/**
37-
* Adds a new asynchronous operation to this instance.
38-
* The operation is provided as a function that returns an {@link Err}.
39-
* If the function encounters an error, it is recorded internally.
40-
*
41-
* @param runner The runner task to be executed asynchronously.
42-
*/
43-
public void add(final Runner runner) {
44-
final var name = this.name;
45-
var vth = Thread.ofVirtual().start(() -> {
46-
try {
47-
runner.run();
48-
} catch (Err | RuntimeException e) {
49-
addErr(name, e);
50-
}
51-
});
52-
vthMap.put(name, vth);
53-
}
54-
55-
synchronized void addErr(String name, Exception exc) {
56-
if (exc instanceof Err) {
57-
errMap.put(name, Err.class.cast(exc));
58-
} else {
59-
errMap.put(name, new Err(new RunnerFailed(), exc));
60-
}
61-
}
62-
63-
Map<String, Err> join() {
64-
for (var ent : vthMap.entrySet()) {
65-
try {
66-
ent.getValue().join();
67-
} catch (InterruptedException e) {
68-
addErr(ent.getKey(), new Err(new RunnerInterrupted(), e));
69-
}
70-
}
12+
public interface AsyncGroup {
13+
record RunnerFailed() {}
14+
record RunnerInterrupted() {}
7115

72-
return errMap;
73-
}
16+
void add(final Runner runner);
7417
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* DataConn class.
3+
* Copyright (C) 2022-2025 Takayuki Sato. All Rights Reserved.
4+
*/
5+
package com.github.sttk.sabi;
6+
7+
import com.github.sttk.errs.Exc;
8+
9+
public interface DataConn {
10+
void commit(AsyncGroup ag) throws Exc;
11+
void preCommit(AsyncGroup ag) throws Exc;
12+
void postCommit(AsyncGroup ag);
13+
boolean shouldForceBack();
14+
void rollback(AsyncGroup ag);
15+
void forceBack(AsyncGroup ag);
16+
void close();
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* DataSrc class.
3+
* Copyright (C) 2022-2025 Takayuki Sato. All Rights Reserved.
4+
*/
5+
package com.github.sttk.sabi;
6+
7+
import com.github.sttk.errs.Exc;
8+
9+
public interface DataSrc {
10+
void setup(AsyncGroup ag) throws Exc;
11+
void close();
12+
DataConn createDataConn() throws Exc;
13+
}

src/main/java/com/github/sttk/sabi/DaxBase.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/main/java/com/github/sttk/sabi/DaxSrc.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)