{"id":29874581,"url":"https://github.com/romanqed/jct","last_synced_at":"2025-07-31T00:42:46.018Z","repository":{"id":306745194,"uuid":"1027091841","full_name":"RomanQed/jct","owner":"RomanQed","description":"Lightweight Java implementation of an operation cancellation mechanism, similar to C#'s CancellationToken.","archived":false,"fork":false,"pushed_at":"2025-07-27T10:01:57.000Z","size":66,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-27T11:42:56.260Z","etag":null,"topics":["abort","async","cancel","cancellation","cancellation-api","cancellationtoken","concurrency","interrupt","java","lightweight","multithreading","token"],"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/RomanQed.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-27T09:46:57.000Z","updated_at":"2025-07-27T10:02:00.000Z","dependencies_parsed_at":"2025-07-27T11:42:58.534Z","dependency_job_id":"6f53f0c7-c972-41fa-bcae-17efb9407c89","html_url":"https://github.com/RomanQed/jct","commit_stats":null,"previous_names":["romanqed/jct"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/RomanQed/jct","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomanQed%2Fjct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomanQed%2Fjct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomanQed%2Fjct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomanQed%2Fjct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RomanQed","download_url":"https://codeload.github.com/RomanQed/jct/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomanQed%2Fjct/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267967816,"owners_count":24173578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["abort","async","cancel","cancellation","cancellation-api","cancellationtoken","concurrency","interrupt","java","lightweight","multithreading","token"],"created_at":"2025-07-31T00:42:41.033Z","updated_at":"2025-07-31T00:42:45.970Z","avatar_url":"https://github.com/RomanQed.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jct [![jct](https://img.shields.io/maven-central/v/com.github.romanqed/jct?strategy=releaseProperty\u0026style=for-the-badge\u0026label=jct\u0026color=blue)](https://repo1.maven.org/maven2/com/github/romanqed/jct)\n\nLightweight Java implementation of an operation cancellation mechanism, similar to C#'s CancellationToken.\nDesigned to be minimal, composable, and runtime-agnostic — works well with standard Java concurrency tools and third-party frameworks.\n\n## Getting Started\n\nTo use this library, you will need:\n\n* Java 11 or higher\n* Maven or Gradle\n\n## Features\n\n* Immutable, thread-safe `CancelToken` abstraction\n* Simple and lightweight cancellation source (`CancelSource`)\n* Composable tokens (linked or combined)\n* Integration with `CompletableFuture` and any asynchronous workflows\n* Memory-friendly: `CancelSource` supports reuse via `reset()`\n\n## Installing\n\n### Gradle dependency\n\n```groovy\ndependencies {\n    implementation group: 'com.github.romanqed', name: 'jct', version: '1.2.0'\n}\n```\n\n### Maven dependency\n\n```xml\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.github.romanqed\u003c/groupId\u003e\n        \u003cartifactId\u003ejct\u003c/artifactId\u003e\n        \u003cversion\u003e1.2.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n## Usage Examples\n\n### Creating a cancelable operation\n\n```java\nCancelSource source = Cancellation.source();\nCancelToken token = source.token();\n\nCompletableFuture\u003cVoid\u003e future = token.onCancelled().thenRun(() -\u003e {\n    System.out.println(\"Cancelled!\");\n});\n\n// Later:\nsource.cancel();\n```\n\n### Combining tokens\n\n```java\nCancelToken token1 = Cancellation.source().token();\nCancelToken token2 = Cancellation.source().token();\n\nCancelToken combined = Cancellation.combinedToken(token1, token2);\n\ncombined.onCancelled().thenRun(() -\u003e {\n    System.out.println(\"Any of the tokens was cancelled\");\n});\n```\n\n### Reusing a source\n\n```java\nCancelSource source = Cancellation.source();\n\n// Use source.token() in one task\nrunCancellableTask(source.token());\n\n// Cancel and reset\nsource.cancel();\nsource.reset();\n\n// Reuse for another task\nrunCancellableTask(source.token());\n```\n\n### Empty token (never cancels)\n\n```java\nCancelToken empty = Cancellation.emptyToken();\n\nempty.onCancelled().thenRun(() -\u003e {\n    // Will never be invoked\n});\n```\n\n## Built With\n\n* [Gradle](https://gradle.org) - Dependency management\n\n## Authors\n\n* **[RomanQed](https://github.com/RomanQed)** - *Main work*\n\nSee also the list of [contributors](https://github.com/RomanQed/jfunc/contributors)\nwho participated in this project.\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromanqed%2Fjct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromanqed%2Fjct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromanqed%2Fjct/lists"}