{"id":15650845,"url":"https://github.com/zonyitoo/simplesched","last_synced_at":"2025-04-30T17:13:19.295Z","repository":{"id":57667445,"uuid":"37539407","full_name":"zonyitoo/simplesched","owner":"zonyitoo","description":"The most naive Coroutine scheduler in Rust","archived":false,"fork":false,"pushed_at":"2016-01-11T03:21:38.000Z","size":224,"stargazers_count":35,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T17:13:13.188Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zonyitoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-16T15:38:24.000Z","updated_at":"2025-02-07T10:51:51.000Z","dependencies_parsed_at":"2022-09-26T20:31:55.534Z","dependency_job_id":null,"html_url":"https://github.com/zonyitoo/simplesched","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonyitoo%2Fsimplesched","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonyitoo%2Fsimplesched/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonyitoo%2Fsimplesched/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonyitoo%2Fsimplesched/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zonyitoo","download_url":"https://codeload.github.com/zonyitoo/simplesched/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251748956,"owners_count":21637418,"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":[],"created_at":"2024-10-03T12:36:03.249Z","updated_at":"2025-04-30T17:13:19.273Z","avatar_url":"https://github.com/zonyitoo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Sched\n\nThe most naive scheduler for Coroutines in Rust.\n\n[![Build Status](https://img.shields.io/travis/zonyitoo/simplesched.svg)](https://travis-ci.org/zonyitoo/simplesched)\n[![Crates.io](\thttps://img.shields.io/crates/l/simplesched.svg)](\thttps://crates.io/crates/simplesched)\n[![Crates.io](\thttps://img.shields.io/crates/v/simplesched.svg)](https://crates.io/crates/simplesched)\n\n## Usage\n\n```toml\n[dependencies]\nsimplesched = \"*\"\n```\n\n### Basic\n\n```rust\nextern crate simplesched;\n\nuse simplesched::Scheduler;\n\nfn main() {\n    Scheduler::spawn(|| {\n        for _ in 0..10 {\n            println!(\"Heil Hydra\");\n        }\n    });\n\n    Scheduler::run(1);\n}\n```\n\n### TCP Echo Server\n\n```rust\nextern crate simplesched;\n\nuse std::io::{Read, Write};\n\nuse simplesched::net::TcpListener;\nuse simplesched::Scheduler;\n\nfn main() {\n    // Spawn a coroutine for accepting new connections\n    Scheduler::spawn(move|| {\n        let acceptor = TcpListener::bind(\"127.0.0.1:8080\").unwrap();\n        println!(\"Waiting for connection ...\");\n\n        for stream in acceptor.incoming() {\n            let mut stream = stream.unwrap();\n\n            println!(\"Got connection from {:?}\", stream.peer_addr().unwrap());\n\n            // Spawn a new coroutine to handle the connection\n            Scheduler::spawn(move|| {\n                let mut buf = [0; 1024];\n\n                loop {\n                    match stream.read(\u0026mut buf) {\n                        Ok(0) =\u003e {\n                            println!(\"EOF\");\n                            break;\n                        },\n                        Ok(len) =\u003e {\n                            println!(\"Read {} bytes, echo back\", len);\n                            stream.write_all(\u0026buf[0..len]).unwrap();\n                        },\n                        Err(err) =\u003e {\n                            println!(\"Error occurs: {:?}\", err);\n                            break;\n                        }\n                    }\n                }\n\n                println!(\"Client closed\");\n            });\n        }\n    });\n\n    // Schedule with 4 threads\n    Scheduler::run(4);\n}\n```\n\nMore examples could be found in `examples`.\n\n## Basic Benchmark\n\n### Test environment\n* OS X 10.10.5 Beta\n* MacBook Pro Late 2013\n* 2.4GHz Intel Core i5\n* 8 GB 1600 MHz DDR3\n\nRelease build. Run the `examples/http-echo-server.rs` with 4 threads, test it with `wrk`:\n\n```\n$ wrk -c 400 -t 2 http://127.0.0.1:8000/\nRunning 10s test @ http://127.0.0.1:8000/\n  2 threads and 400 connections\n  Thread Stats   Avg      Stdev     Max   +/- Stdev\n    Latency     7.07ms    4.58ms  78.12ms   83.27%\n    Req/Sec    29.07k     3.80k   39.00k    76.00%\n  578941 requests in 10.04s, 51.90MB read\n  Socket errors: connect 0, read 101, write 0, timeout 0\nRequests/sec:  57667.33\nTransfer/sec:      5.17MB\n```\n\nGo 1.4.2 example HTTP echo server, with `GOMAXPROCS=4`:\n\n```\n$ wrk -c 400 -t 2 http://127.0.0.1:8000/\nRunning 10s test @ http://127.0.0.1:8000/\n  2 threads and 400 connections\n  Thread Stats   Avg      Stdev     Max   +/- Stdev\n    Latency     6.01ms    3.68ms  96.42ms   84.52%\n    Req/Sec    29.32k     6.53k   51.77k    71.21%\n  583573 requests in 10.05s, 75.13MB read\n  Socket errors: connect 0, read 35, write 0, timeout 0\nRequests/sec:  58084.36\nTransfer/sec:      7.48MB\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonyitoo%2Fsimplesched","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzonyitoo%2Fsimplesched","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonyitoo%2Fsimplesched/lists"}