触发FileIO.toPath接收器完成

时间:2018-11-22 19:30:03

标签: akka akka-stream

我有一个IO源,正在多路复用一个文件,然后移交给系统的另一部分以执行,如:

source.alsoTo(FileIO.toPath(path))

这用于缓存,即我正在将通过系统的文件写入临时缓存位置。写入缓存后,我想将其原子地移动到其最终位置。

源的使用者获得Future并知道何时完成,但是我在通道上写入文件到磁盘的旁通道没有这种功能。有什么方法可以将完成处理程序附加到接收器,以便我可以完成对该文件的操作?

1 个答案:

答案 0 :(得分:2)

使用private void Generate() { for (int i = 0; i <= 5; i++) { Vector3 pos = PointsGenerator(); Instantiate(point, pos, Quaternion.identity); // just to highlight the points on the screen } } private List<Vector3> Dist = new List<Vector3>(); private bool isOver = false; private Vector3 PointsGenerator() { Vector3 currentPosition = Vector3.zero; Vector3 oldPosition = Vector3.zero; float distance = 0f; do { currentPosition = new Vector3(UnityEngine.Random.Range(minX, maxX), UnityEngine.Random.Range(minY, maxY), 0f); for (int i = 0; i < Dist.Count; i++) { distance = Vector2.Distance(currentPosition, Dist[i]); if (distance <= 4f) { isOver = true; break; } else isOver = false; } } while (isOver == true); Dist.Add(currentPosition); return currentPosition; } const getMin = (data, index) => data.reduce((prev, current) => (prev.coords[index] < current.coords[index] ? prev : current)) .coords[index]; const getMax = (data, index) => data.reduce((prev, current) => (prev.coords[index] > current.coords[index] ? prev : current)) .coords[index]; const getBounds = data => [ { lat: getMin(data, 0), lng: getMin(data, 1) }, { lat: getMax(data, 0), lng: getMax(data, 1) } ]; 代替alsoTo来访问文件alsoToMat的物化值:

mapMaterializedValue