タグ

syncに関するsgykfjsmのブックマーク (2)

  • sync.ErrGroupで複数のgoroutineを制御する

    Golangの並行処理は強力である一方で同期処理を慎重に実装する必要がある.“Go 言語における並行処理の構築部材”にまとめられているようにGolangは様々な方法でそれを実装することができる.実現したいタスクに合わせてこれらを適切に選択する必要がある. この同期処理の機構として新たにgolang.org/x/sync/errgroupというパッケージが登場した.実際に自分のツールで使ってみて便利だったので簡単に紹介する. 使いどころ 時間のかかる1つのタスクを複数のサブタスクとして並行実行しそれらが全て終了するのを待ち合わせる処理(Latch)を書きたい場合にerrgroupは使える.その中でも「1つでもサブタスクでエラーが発生した場合に他のサブタスクを全てを終了しエラーを返したい」(複数のサブタスクが全て正常に終了して初めて1つの処理として完結する)場合が主な使いどころである. 実例

  • Syncthing

    The Syncthing Foundation stands for peace and with Ukraine! Read about what we're doing. Syncthing is a continuous file synchronization program. It synchronizes files between two or more computers in real time, safely protected from prying eyes. Your data is your data alone and you deserve to choose where it is stored, whether it is shared with some third party, and how it’s transmitted over the i

  • 1