func downSample(imageAt imageURL: URL, to pointSize: CGSize, scale: CGFloat) -> UIImage {
	let imageSourceOptions = [kCGImageSourceShouldCache: false] as CFDictionary
	let imageSource = CGImageSourceCreateWithURL(imageURL as CFURL, imageSourceOptions)!
	
	let maxDimensionInPixels = max(pointSize.width, pointSize.heihgt) * scale
	
	let downsampleOptions = [
		kCGImageSourceCreateThumbnailFromImageAlways: true,
		kCGImageSourceShouldCacheImmediately: true, // core graphics에게 해당 이미지로 이미지 버퍼를 만들 것임을 알려주는 역할 
		kCGImageSourceCreateThumbnailWithTransform: true,
		kCGImageSourceThumbnailMaxPixelSize: maxDimentionInPixels] as CFDictionary

	let downsampledImage = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, downsampleOptions)!

	return UIImage(cgImage: downsampledImage)
}

func collectionView(_ collectionView: UICollectionView,
						prefecthItemsAt indexPaths [IndexPath]) {

// concurrent큐로 하면 스레드 폭발의 위험성이 있다.
// serial Queue를 만들어서 해라
	for indexPath in indexPaths {
		Dispatchqueue.global(qos: .userInitiated).async {
			let downsampledImage = downsample(images[indexPath.row])

			DispatchQueue.main.async { self.update(at: indexPath, with: downsampledImage) }

		}
	}
}