Class: COS::Checkpoint

Inherits:
Struct::Base show all
Defined in:
lib/cos/checkpoint.rb

Direct Known Subclasses

Download, Slice

Constant Summary collapse

DEFAULT_THREADS =

默认线程数 10

10

Instance Method Summary collapse

Methods included from Struct::Base::AttrHelper

#optional_attrs, #required_attrs

Constructor Details

#initialize(options = {}) ⇒ Checkpoint

Returns a new instance of Checkpoint.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cos/checkpoint.rb', line 12

def initialize(options = {})
  super(options)

  # 分片大小必须>0
  if options[:options] and options[:options][:slice_size] and options[:options][:slice_size] <= 0
    raise ClientError, 'slice_size must > 0'
  end

  @mutex = Mutex.new
  @file_meta   = {}
  @num_threads = options[:threads] || DEFAULT_THREADS
  @all_mutex   = Mutex.new
  @parts       = []
  @todo_mutex  = Mutex.new
  @todo_parts  = []
end