MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenImageIO / add_tile_to_cache

Method add_tile_to_cache

src/libtexture/imagecache.cpp:1919–1957  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1917
1918
1919void
1920ImageCacheImpl::add_tile_to_cache (ImageCacheTileRef &tile,
1921 ImageCachePerThreadInfo *thread_info)
1922{
1923 bool ourtile = true;
1924 {
1925 // Protect us from using too much memory if another thread added the
1926 // same tile just before us
1927 TileCache::iterator found = m_tilecache.find (tile->id());
1928 if (found != m_tilecache.end ()) {
1929 // Already added! Use the other one, discard ours.
1930 tile = (*found).second;
1931 found.unlock ();
1932 ourtile = false; // Don't need to add it
1933 } else {
1934 // Still not in cache, add ours to the cache.
1935 // N.B. at this time, we do not hold any locks.
1936 check_max_mem (thread_info);
1937 m_tilecache.insert (tile->id(), tile);
1938 }
1939 }
1940
1941 // At this point, we no longer have the write lock, and we are no
1942 // longer modifying the cache itself. However, if we added a new
1943 // tile to the cache, we may still need to read the pixels; and if
1944 // we found the tile in cache, we may need to wait for somebody else
1945 // to read the pixels.
1946 if (ourtile) {
1947 if (! tile->pixels_ready ()) {
1948 Timer timer;
1949 tile->read (thread_info);
1950 double readtime = timer();
1951 thread_info->m_stats.fileio_time += readtime;
1952 tile->id().file().iotime() += readtime;
1953 }
1954 } else {
1955 tile->wait_pixels_ready ();
1956 }
1957}
1958
1959
1960

Callers 1

read_untiledMethod · 0.80

Calls 6

pixels_readyMethod · 0.80
wait_pixels_readyMethod · 0.80
findMethod · 0.45
endMethod · 0.45
unlockMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected