Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

循环依赖是怎么避免的? #4

Closed
forever4313 opened this issue Sep 27, 2019 · 3 comments
Closed

循环依赖是怎么避免的? #4

forever4313 opened this issue Sep 27, 2019 · 3 comments

Comments

@forever4313
Copy link

看到有这么一段注释

 * project 的构建内部,避免了回环的发生。
 * 当出现project 内 task 循环依赖是,循环依赖会自动断开。

是怎么做到依赖自动断开的呢?
顺便想问一下,
如果使用如下build构建
builder1.add(TASK_11).dependOn(TASK_10);
builder1.add(TASK_12).dependOn(TASK_11);
builder1.add(TASK_13).dependOn(TASK_12);

从startTask就只能运行 START->FINISH 两个task

@YummyLau
Copy link
Collaborator

针对你的例子,因为你丢失了 TASK_10,所以 project1中 startTask任务结束之后获取 TASK_10,发现task对象不存在则丢弃。
真正检测回环的逻辑在 AnchorsRuntime#getDependenciesMaxDepth, 存在死循环的时候框架会抛出异常,这对程序设计是合理的。

@forever4313
Copy link
Author

哦,明白了,实际上,Add才是真正的在图中增加一个task,dependon只是为了增加对应的依赖关系

@YummyLau
Copy link
Collaborator

哦,明白了,实际上,Add才是真正的在图中增加一个task,dependon只是为了增加对应的依赖关系

嗯嗯对的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants