Class: BBFS::ContentData::DynamicContentData

Inherits:
Object
  • Object
show all
Defined in:
lib/content_data/dynamic_content_data.rb

Overview

TODO(kolman): When content data is immutable, remove the clones (waste).

Instance Method Summary collapse

Constructor Details

#initializeDynamicContentData

Returns a new instance of DynamicContentData.



8
9
10
11
# File 'lib/content_data/dynamic_content_data.rb', line 8

def initialize()
  @last_content_data = nil
  @last_content_data_available_mutex = Mutex.new
end

Instance Method Details

#exists?(checksum) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/content_data/dynamic_content_data.rb', line 20

def exists?(checksum)
  ref = nil
  @last_content_data_available_mutex.synchronize {
    ref = @last_content_data
  }
  #Log.debug3("@last_content_data is nil? #{@last_content_data.nil?}")
  #Log.debug3(@last_content_data.to_s) unless @last_content_data.nil?
  #Log.debug3("Exists?:#{@last_content_data.content_exists(checksum)}") \
  #         unless @last_content_data.nil?
  return ref.content_exists(checksum) if ref != nil
  false
end

#last_content_dataObject



33
34
35
36
37
38
39
# File 'lib/content_data/dynamic_content_data.rb', line 33

def last_content_data
  ref = nil
  @last_content_data_available_mutex.synchronize {
    ref = @last_content_data
  }
  return ContentData.new(ref)
end

#update(content_data) ⇒ Object



13
14
15
16
17
18
# File 'lib/content_data/dynamic_content_data.rb', line 13

def update(content_data)
  ref = ContentData.new(content_data)
  @last_content_data_available_mutex.synchronize {
    @last_content_data = ref
  }
end