This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "file-downloader" | |
version = "0.1.0" | |
edition = "2021" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
reqwest = { version = "0.11", features=["stream"]} | |
tokio = { version = "1.26.0", features=["fs", "full"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
progress_bar() { | |
current=$1 | |
total=$2 | |
progress=$(($current * 100 / ${total})) | |
bar="$(yes '#' | head -n ${progress} | tr -d '\n')" | |
if [ -z "$bar" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias AsyncCallback = () -> Void | |
func getFriends() { | |
let dispatchGroup = DispatchGroup() | |
let dispatchQueue = DispatchQueue(label: "twitterAPIQueue", attributes: .concurrent) | |
// 非同期のGroupとQueueに書くメソッドを割り当てる | |
dispatch(group: dispatchGroup, queue: dispatchQueue, method: getFollows) | |
dispatch(group: dispatchGroup, queue: dispatchQueue, method: getFollowers) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getFriends() { | |
let numberOfParallel: Int = 2 | |
var completionCount: Int = 0 | |
// 呼ばれるたびに 1ずつ足していって並列実行数を超えたら何かのメソッドを呼ぶ | |
completion = []() { | |
completionCount += 1 | |
if (numberOfParallel >= comletionCount) { | |
// 突合する処理など | |
doSomethingAfterFetchFriends() |