├── .gitignore
├── jitpack.yml
├── pom.xml
└── src
└── main
└── java
└── io
└── github
└── evacchi
├── Actor.java
├── App.java
├── TypedActor.java
├── Weather.java
├── asyncchat
├── ChannelActor.java
├── ChatClient.java
└── ChatServer.java
├── chat
├── BlockingChat.java
├── ChatClient.java
└── ChatServer.java
└── typed
└── examples
├── HelloWorld.java
├── PingPong.java
├── VendingMachine.java
└── VendingMachineAlt.java
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .classpath
3 | .project
4 | .settings/
5 | target/
6 |
7 |
--------------------------------------------------------------------------------
/jitpack.yml:
--------------------------------------------------------------------------------
1 | jdk:
2 | - oraclejdk17
3 | before_install:
4 | - curl -Ls https://sh.jbang.dev | bash -s - app setup
5 | install:
6 | - cd src/main/java/io/github/evacchi/
7 | - ~/.jbang/bin/jbang export mavenrepo --force -O target -Dgroup=$GROUP -Dartifact=$ARTIFACT -Dversion=$VERSION Actor.java
8 | - mkdir -p ~/.m2/repository
9 | - cp -rv target/* ~/.m2/repository/
10 |
11 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 |
7 | com.github.evacchi
8 | min-java-actors
9 | 1.0-SNAPSHOT
10 |
11 | min-java-actors
12 |
13 | http://www.example.com
14 |
15 |
16 | UTF-8
17 | 17
18 | 17
19 |
20 |
21 |
22 |
23 | centralhttps://repo1.maven.org/maven2/
24 | jitpackhttps://jitpack.io
25 |
26 |
27 |
28 |
29 | com.github.evacchi
30 | java-async-channels
31 | main-SNAPSHOT
32 |
33 |
34 | com.fasterxml.jackson.core
35 | jackson-databind
36 | 2.13.0
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | maven-clean-plugin
47 | 3.1.0
48 |
49 |
50 |
51 | maven-resources-plugin
52 | 3.0.2
53 |
54 |
55 | maven-compiler-plugin
56 | 3.8.0
57 |
58 |
59 | maven-surefire-plugin
60 | 2.22.1
61 |
62 |
63 | maven-jar-plugin
64 | 3.0.2
65 |
66 |
67 | maven-install-plugin
68 | 2.5.2
69 |
70 |
71 | maven-deploy-plugin
72 | 2.8.2
73 |
74 |
75 |
76 | maven-site-plugin
77 | 3.7.1
78 |
79 |
80 | maven-project-info-reports-plugin
81 | 3.0.0
82 |
83 |
84 |
85 |
86 |
87 | org.apache.maven.plugins
88 | maven-compiler-plugin
89 |
90 | 17
91 | 17
92 | --enable-preview
93 |
94 |
95 |
96 | org.codehaus.mojo
97 | exec-maven-plugin
98 | 3.0.0
99 |
100 |
101 | server
102 |
103 | java
104 |
105 |
106 | io.github.evacchi.chat.ChatServer
107 |
108 |
109 |
110 | client
111 |
112 | java
113 |
114 |
115 | io.github.evacchi.chat.ChatClient
116 |
117 |
118 |
119 | asyncserver
120 |
121 | java
122 |
123 |
124 | io.github.evacchi.asyncchat.ChatServer
125 |
126 |
127 |
128 | asyncclient
129 |
130 | java
131 |
132 |
133 | io.github.evacchi.asyncchat.ChatClient
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/src/main/java/io/github/evacchi/Actor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Inspired by Viktor Klang's minscalaactors.scala
3 | * https://gist.github.com/viktorklang/2362563
4 | * Copyright 2014 Viktor Klang
5 | *
6 | * Copyright 2021 Edoardo Vacchi
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | *
20 | */
21 |
22 | //JAVA 17
23 | //JAVAC_OPTIONS --enable-preview --release 17
24 | //JAVA_OPTIONS --enable-preview
25 |
26 | package io.github.evacchi;
27 |
28 | import java.util.concurrent.*;
29 | import java.util.concurrent.atomic.AtomicInteger;
30 | import java.util.function.Function;
31 | import static java.lang.System.out;
32 |
33 | public interface Actor {
34 | interface Behavior extends Function