diff options
author | Toshiaki Asai <toshi.alternative@gmail.com> | 2016-11-20 04:53:41 +0900 |
---|---|---|
committer | Toshiaki Asai <toshi.alternative@gmail.com> | 2016-11-27 11:43:00 +0900 |
commit | ce9d31edd3b7e350fb4c718b483152fed0bee7f8 (patch) | |
tree | 16361ed8eda6f725453552f00e2484799a6af884 | |
parent | b34cf1a545f512dded77926b032aa342f1e453ae (diff) | |
download | mikutter-ce9d31edd3b7e350fb4c718b483152fed0bee7f8.tar.gz |
PhotoModelによって同時にダウンロードされる画像点数を4つに制限 refs #934
-rw-r--r-- | core/lib/retriever/mixin/photo_mixin.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/lib/retriever/mixin/photo_mixin.rb b/core/lib/retriever/mixin/photo_mixin.rb index 7dea337d..624ce2ba 100644 --- a/core/lib/retriever/mixin/photo_mixin.rb +++ b/core/lib/retriever/mixin/photo_mixin.rb @@ -7,6 +7,8 @@ このmoduleをincludeしたクラスは、必要に応じて _download_routine_ をオーバライドする =end module Retriever::Model::PhotoMixin + DownloadThread = SerialThreadGroup.new(max_threads: 4, deferred: Delayer::Deferred) + def self.included(klass) klass.field.string :blob end @@ -70,7 +72,7 @@ module Retriever::Model::PhotoMixin atomic do return download(&partial_callback) unless ready? promise = initialize_download(&partial_callback) - Thread.new(&method(:cache_read_or_download)).next{|success| + DownloadThread.new(&method(:cache_read_or_download)).next{|success| if success finalize_download_as_success else |