{"id":19329038,"url":"https://github.com/ncornette/superinit","last_synced_at":"2025-02-24T06:42:19.344Z","repository":{"id":146101060,"uuid":"69679379","full_name":"ncornette/superinit","owner":"ncornette","description":"Async dependency tree loader","archived":false,"fork":false,"pushed_at":"2018-09-18T12:39:05.000Z","size":155,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-06T07:49:07.205Z","etag":null,"topics":["dependency-graph","init-system","thread","threadpool"],"latest_commit_sha":null,"homepage":null,"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/ncornette.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2016-09-30T15:39:47.000Z","updated_at":"2020-11-23T03:58:01.000Z","dependencies_parsed_at":"2023-04-17T22:15:53.750Z","dependency_job_id":null,"html_url":"https://github.com/ncornette/superinit","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncornette%2Fsuperinit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncornette%2Fsuperinit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncornette%2Fsuperinit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncornette%2Fsuperinit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ncornette","download_url":"https://codeload.github.com/ncornette/superinit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240434194,"owners_count":19800548,"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","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":["dependency-graph","init-system","thread","threadpool"],"created_at":"2024-11-10T02:26:17.454Z","updated_at":"2025-02-24T06:42:19.229Z","avatar_url":"https://github.com/ncornette.png","language":"Java","readme":"[![Build Status](https://travis-ci.org/ncornette/superinit.svg?branch=master)](https://travis-ci.org/ncornette/superinit)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b9b30724b03149f3abde10c021be7437)](https://www.codacy.com/app/nicolas-cornette/superinit?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=ncornette/superinit\u0026amp;utm_campaign=Badge_Grade)\n[![codecov](https://codecov.io/gh/ncornette/superinit/branch/master/graph/badge.svg)](https://codecov.io/gh/ncornette/superinit)\n[ ![Download](https://api.bintray.com/packages/ncornette/maven/superinit/images/download.svg) ](https://bintray.com/ncornette/maven/superinit/_latestVersion)\n\n# Superinit\n\nAsync dependency tree loader\n\n## Gradle\n\n```groovy\n\nrepositories {\n    jcenter()\n}\n\ndependencies {\n\t// Your dependencies\n\t...\n\n\t// Async dependency tree loader\n    // https://github.com/ncornette/superinit\n    compile 'com.ncornette.superinit:superinit:0.9.7'\n}\n```\n\n## Usage\n\nWrap any `Runnable` into a `InitNode` object, then define dependencies :\n\n\n```java\n    InitNode nodeA = new InitNode(runnableA);\n    InitNode nodeB = new InitNode(runnableB);\n    InitNode nodeC = new InitNode(runnableC);\n\n    // Setup dependencies\n    nodeA.dependsOn(nodeB);\n\n```\n\nThen use `InitLoader.load()` to execute all nodes in order based on dependencies, and in parallel when possible.\n\n```java\n\n    InitLoader initLoader =  new InitLoader(3); // N Threads in Thread pool executor\n\n    // Execute tasks\n    initLoader.load(loaderCallback, nodeA, nodeB, nodeC);\n\n```\n\nUse the `InitLoaderCallback` interface to be notified of the `InitLoader`\n\n```java\npublic interface InitLoaderCallback {\n\n    // Is called once on success, even if error occurred\n    // Not called if InitLoader.interrupt() is called during execution \n    void onFinished();\n\n    // Is called each time a node execution fails with an Exception\n    void onNodeError(NodeExecutionError nodeError);\n\n    // Is called when an exception occurs outside a node execution\n    void onError(Throwable error);\n\n}\n```\n\n## Features\nA `ThreadpoolExecutor` with a fixed number of Threads will excute the tasks. Even with One Thread, execution order \nis guaranteed to be respected.\n\nCircular dependencies are prevented as early as possible, and will throw `IllegalArgumentException` :  \n\n - When adding a dependency with `dependsOn()` for direct circular dependencies.\n - When calling `Initloader.load()` for indirect circular dependencies.\n\nNodes use `CountDownLatch` to wait for execution of their dependencies and to notify their execution is finished.\n\n\n\n## Reference\n\n[Dependency Resolving Algorithm](http://www.electricmonk.nl/docs/dependency_resolving_algorithm/dependency_resolving_algorithm.html)\n\n\n## License\n\n    Copyright 2016 Nicolas Cornette\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncornette%2Fsuperinit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fncornette%2Fsuperinit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncornette%2Fsuperinit/lists"}