[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EGDVP9TT55J2S4Y3XHDD2T":3,"skill-same:01M6EGDVP9TT55J2S4Y3XHDD2T":51},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":25,"repositoryHtmlUrl":26,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M6EGDVP9TT55J2S4Y3XHDD2T","tokio",null,"ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FTerminalSkills\u002Fskills\u002Ftokio\u002FSKILL.md",[],[5],"2026-11-10 10:12:30",false,"# Tokio — Async Runtime for Rust\n\nYou are an expert in Tokio, the asynchronous runtime for Rust that powers most of the Rust async ecosystem. You help developers build high-performance network applications, concurrent services, and I\u002FO-bound systems using Tokio's task scheduler, async I\u002FO primitives, channels, timers, and synchronization utilities — handling millions of concurrent connections with minimal memory overhead.\n\n## Core Capabilities\n\n### Async Tasks\n\n```rust\nuse tokio::time::{sleep, Duration};\nuse tokio::task;\n\n#[tokio::main]\nasync fn main() {\n    \u002F\u002F Spawn concurrent tasks\n    let handle1 = task::spawn(async {\n        sleep(Duration::from_secs(1)).await;\n        \"Task 1 done\"\n    });\n\n    let handle2 = task::spawn(async {\n        sleep(Duration::from_millis(500)).await;\n        \"Task 2 done\"\n    });\n\n    \u002F\u002F Await both\n    let (r1, r2) = tokio::join!(handle1, handle2);\n    println!(\"{}, {}\", r1.unwrap(), r2.unwrap());\n\n    \u002F\u002F Select first to complete\n    tokio::select! {\n        val = async { sleep(Duration::from_secs(1)).await; \"slow\" } => {\n            println!(\"Got: {val}\");\n        }\n        val = async { sleep(Duration::from_millis(100)).await; \"fast\" } => {\n            println!(\"Got: {val}\");\n        }\n    }\n\n    \u002F\u002F Spawn blocking work (CPU-intensive) on dedicated thread pool\n    let result = task::spawn_blocking(|| {\n        heavy_computation()                \u002F\u002F Won't block async runtime\n    }).await.unwrap();\n}\n```\n\n### Channels\n\n```rust\nuse tokio::sync::{mpsc, broadcast, oneshot, watch};\n\n\u002F\u002F mpsc: Multiple producers, single consumer\nlet (tx, mut rx) = mpsc::channel::\u003CString>(100);  \u002F\u002F Buffer size 100\nlet tx2 = tx.clone();\n\ntask::spawn(async move { tx.send(\"hello\".into()).await.unwrap(); });\ntask::spawn(async move { tx2.send(\"world\".into()).await.unwrap(); });\n\nwhile let Some(msg) = rx.recv().await {\n    println!(\"Got: {msg}\");\n}\n\n\u002F\u002F broadcast: Multiple producers, multiple consumers\nlet (tx, _) = broadcast::channel::\u003CString>(100);\nlet mut rx1 = tx.subscribe();\nlet mut rx2 = tx.subscribe();\ntx.send(\"event\".into()).unwrap();\n\u002F\u002F Both rx1 and rx2 receive \"event\"\n\n\u002F\u002F oneshot: Single value, single use (request-response)\nlet (tx, rx) = oneshot::channel::\u003CString>();\ntx.send(\"response\".into()).unwrap();\nlet val = rx.await.unwrap();\n\n\u002F\u002F watch: Single value that can be updated and observed\nlet (tx, mut rx) = watch::channel(\"initial\".to_string());\ntx.send(\"updated\".into()).unwrap();\nrx.changed().await.unwrap();\n```\n\n### TCP Server\n\n```rust\nuse tokio::net::TcpListener;\nuse tokio::io::{AsyncReadExt, AsyncWriteExt};\n\n#[tokio::main]\nasync fn main() -> std::io::Result\u003C()> {\n    let listener = TcpListener::bind(\"0.0.0.0:8080\").await?;\n\n    loop {\n        let (mut socket, addr) = listener.accept().await?;\n        println!(\"New connection from {addr}\");\n\n        tokio::spawn(async move {\n            let mut buf = vec![0u8; 1024];\n            loop {\n                let n = match socket.read(&mut buf).await {\n                    Ok(0) => return,       \u002F\u002F Connection closed\n                    Ok(n) => n,\n                    Err(e) => { eprintln!(\"Read error: {e}\"); return; }\n                };\n                if socket.write_all(&buf[..n]).await.is_err() {\n                    return;                \u002F\u002F Write error\n                }\n            }\n        });\n    }\n}\n```\n\n### Synchronization\n\n```rust\nuse tokio::sync::{Mutex, RwLock, Semaphore};\nuse std::sync::Arc;\n\n\u002F\u002F Async Mutex (yields while waiting, doesn't block thread)\nlet data = Arc::new(Mutex::new(vec![1, 2, 3]));\nlet data_clone = data.clone();\ntokio::spawn(async move {\n    let mut lock = data_clone.lock().await;\n    lock.push(4);\n});\n\n\u002F\u002F RwLock: Multiple readers OR single writer\nlet cache = Arc::new(RwLock::new(HashMap::new()));\nlet read = cache.read().await;             \u002F\u002F Non-exclusive\nlet mut write = cache.write().await;       \u002F\u002F Exclusive\n\n\u002F\u002F Semaphore: Limit concurrency\nlet semaphore = Arc::new(Semaphore::new(10));  \u002F\u002F Max 10 concurrent\nlet permit = semaphore.acquire().await.unwrap();\n\u002F\u002F ... do work ...\ndrop(permit);                              \u002F\u002F Release\n```\n\n## Installation\n\n```toml\n[dependencies]\ntokio = { version = \"1\", features = [\"full\"] }\n# Or selectively: features = [\"rt-multi-thread\", \"macros\", \"net\", \"io-util\", \"time\", \"sync\"]\n```\n\n## Best Practices\n\n1. **Don't block the runtime** — Use `spawn_blocking` for CPU-intensive or synchronous I\u002FO; blocking async threads starves other tasks\n2. **Use channels for communication** — mpsc for work queues, broadcast for events, watch for config updates\n3. **Select for racing** — `tokio::select!` picks the first future to complete; great for timeouts and cancellation\n4. **Async Mutex vs std Mutex** — Use `tokio::sync::Mutex` when holding lock across `.await`; std Mutex for short, sync-only locks\n5. **Semaphores for backpressure** — Limit concurrent database queries, HTTP requests, or file operations\n6. **Graceful shutdown** — Use `tokio::signal::ctrl_c()` + cancellation tokens to drain work before exiting\n7. **Runtime configuration** — Use `#[tokio::main]` for defaults; `runtime::Builder` for custom thread counts and stack sizes\n8. **Tracing integration** — Use `tracing` crate with Tokio; spans propagate across async task boundaries automatically\n",{},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002FTerminalSkills\u002Fskills\u002Ftokio",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":7,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill tokio",{"tool":37,"command":38},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill tokio",{"tool":40,"command":41},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill tokio","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FTerminalSkills\u002Fskills\u002Ftokio\u002FSKILL.md",true,[45],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"templates.md","REFERENCE","参考文档",43060,"https:\u002F\u002Fgithub.com\u002Fvitalikpestov\u002FSkills-Catalog\u002Fblob\u002Fmain\u002F_Mobile-Dev\u002Ffrom-article-18-ui-ux\u002Fclaude-code-apple-skills\u002Fskills\u002Fgenerators\u002Fsocial-export\u002Ftemplates.md",[52,61,70,79,85,91],{"skillNo":53,"name":54,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":18},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[58,59,60],"model","model hierarchy","model hierarchy skill",{"skillNo":62,"name":63,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":18},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[67,68,69],"MCP","zoom","zoom mcp",{"skillNo":71,"name":72,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[76,77,78,68],"sdk","zoom apps sdk","apps",{"skillNo":80,"name":81,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[81],{"skillNo":86,"name":87,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":18},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[87],{"skillNo":92,"name":93,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":18},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[93]]