{"id":33179638,"url":"https://github.com/zakgof/actr","last_synced_at":"2026-01-12T08:41:53.042Z","repository":{"id":55351805,"uuid":"174973188","full_name":"zakgof/actr","owner":"zakgof","description":"Simple, fast and typesafe Java actor model implementation","archived":false,"fork":false,"pushed_at":"2022-08-24T18:39:11.000Z","size":178,"stargazers_count":113,"open_issues_count":5,"forks_count":19,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-03-21T12:00:39.820Z","etag":null,"topics":["actor-model","actors","akka","concurrency","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zakgof.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-11T10:04:08.000Z","updated_at":"2024-03-11T08:56:15.000Z","dependencies_parsed_at":"2022-08-14T22:01:23.261Z","dependency_job_id":null,"html_url":"https://github.com/zakgof/actr","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/zakgof/actr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakgof%2Factr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakgof%2Factr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakgof%2Factr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakgof%2Factr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zakgof","download_url":"https://codeload.github.com/zakgof/actr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakgof%2Factr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28337599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actor-model","actors","akka","concurrency","java"],"created_at":"2025-11-16T03:00:36.839Z","updated_at":"2026-01-12T08:41:53.028Z","avatar_url":"https://github.com/zakgof.png","language":"Java","funding_links":[],"categories":["并发编程","\u003ca name=\"Java\"\u003e\u003c/a\u003eJava"],"sub_categories":[],"readme":"## actr\r\n![Travis CI](https://travis-ci.org/zakgof/actr.svg?branch=release)\r\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.zakgof/actr/badge.svg)](https://mvnrepository.com/artifact/com.github.zakgof/actr)\r\n\r\nSimple actor model implementation for Java\r\n\r\n- Simple API: sending _ask_ and _tell_ messages is just calling class methods\r\n- POJOs as Actors: focus on business logics, no need to extend any frameworks classes\r\n- Type safe: no need for instanceof/cast, compile time check prevents sending wrong message to a wrong actor\r\n- High performance: lock-free implementation and lightweight actor creation\r\n\r\nActor code is guaranteed to be executed in thread-safe context:\r\n- no concurrent calls for a particular actor (although subsequent calls may be dispatched to different threads)\r\n- actor state can be safely read/written from actor code without any synchronized/volatile specifiers\r\n\r\nActr's API philosophy is discussed here: https://medium.com/@zakgof/type-safe-actor-model-for-java-7133857a9f72\r\n\r\n#### Schedulers\r\n\r\nSchedulers are available to be configured on per-actor or per-actor-system basis.\r\n\r\n- Shared ForkJoinPool scheduler (the default)    \r\nAll actors share the common work stealing `ForkJoinPool`. This option is best for CPU-intensive actors.\r\n\r\n- Thread per actor (pinned thread) scheduler    \r\nEach actor owns a thread and all calls to the actor execute in that dedicated thread. It is useful, in particular, when wrapping non thread safe API.\r\n**NEW !** JDK's project Loom Virtual Threads are also supported - check this article: https://medium.com/@zakgof/a-simple-benchmark-for-jdk-project-looms-virtual-threads-4f43ef8aeb1\r\n\r\n- Fixed thread pool scheduler    \r\nUses a pool of a predefined number or threads for scheduling actor calls. It might be beneficial compared to ForkJoinPools for actors involving some io when actor's CPU utilization is not maximum.\r\n\r\n- Scheduler based on a user-provided ExecutorService for a more flexible option.   \r\n\r\nIt's easy to introduce your own fine-tuned scheduler by just implementing `IActorScheduler`.\r\n\r\n#### Comparison to akka\r\n\r\nAkka will require more boilerplate code. Code with Actr will be more concise.\r\n\r\n|  | Akka | Actr |\r\n| ------------- | ------------- | ------------- |\r\n| Type safety  | No. Sending any message to any actor won't reveal any problems at compile time|  Type safe |\r\n| Actor implementation class  | Must extend AbstractActor |  No constraints |\r\n| Message | Must create a class for every message type | Message type is represented by a method |\r\n| Message type dispatching | Must implement dispatching| Message type = method, no need for implementing dispatching |\r\n| Passing multiple params | Must pack into a single message class | Message type = method, so supported  |\r\n\r\nCompare the same example implemented with\r\n[akka](https://github.com/akka/akka-quickstart-java.g8/tree/2.5.x/src/main/g8/src/main/java/com/lightbend/akka/sample) and [actr](https://github.com/zakgof/actr/tree/master/src/example/java/com/zakgof/actr/vsakka). (Note the difference in Printer implementation. With akka, the implementation is 41 lines long with only 1 line of business code (line 34))\r\n\r\n#### Performance\r\nActr outperforms Akka on common actor operations. A complete opensource benchmark is available here: https://github.com/zakgof/akka-actr-benchmark\r\n\r\n### Setup\r\nActr is on Maven Central\r\n\r\n#### Gradle\r\n````groovy\r\nimplementation 'com.github.zakgof:actr:0.4.2'\r\n````\r\n\r\n#### Maven\r\n````xml\r\n\u003cdependency\u003e\r\n  \u003cgroupId\u003ecom.github.zakgof\u003c/groupId\u003e\r\n  \u003cartifactId\u003eactr\u003c/artifactId\u003e\r\n  \u003cversion\u003e0.4.2/version\u003e\r\n\u003c/dependency\u003e\r\n````\r\n\r\n### Usage\r\n\r\nHaving a POJO class\r\n````java\r\nprivate static class Printer {\r\n\r\n    public void print(String s) {\r\n        // This is called in Printer's thread\r\n        System.err.println(\"[Printer] \" + s);\r\n    }\r\n    public String getName() {\r\n        // This is called in Printer's thread\r\n        return \"Printer-1\";\r\n    }\r\n}\r\n````\r\n\r\nCreate an actor\r\n\r\n````java\r\nfinal IActorRef\u003cPrinter\u003e printerActor = Actr.newActorSystem(\"default\").actorOf(Printer::new);\r\n````\r\n\r\nCall Printer from another actor\r\n````java\r\n\r\n\r\n    public void run() {\r\n        // Tell: send text to print\r\n        printerActor.tell(printer -\u003e printer.print(\"Hello !\"));\r\n        \r\n        // Ask: retrieve printer name. Printer#getName runs in Printer's thread, #printerNameReply runs in Caller's thread\r\n        printerActor.ask(Printer::getName, this::printerNameReceived);\r\n    }\r\n    \r\n    private void printerNameReceived(String printerName) {\r\n       // Do smth with Printer's name\r\n       // This is called in Caller's thread\r\n    }\r\n    \r\n\r\n````\r\n\r\n### More examples\r\nhttps://github.com/zakgof/actr/tree/master/src/example/java/com/zakgof/actr/example\r\n\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakgof%2Factr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzakgof%2Factr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakgof%2Factr/lists"}