Skip to content

Commit 693816a

Browse files
authored
Merge pull request Kotlin#4 from qiaoyuang/master
翻译《取消与超时》
2 parents d4e4901 + bba968d commit 693816a

File tree

2 files changed

+97
-97
lines changed

2 files changed

+97
-97
lines changed

docs/basics.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ World!
8383
Error: Kotlin: Suspend functions are only allowed to be called from a coroutine or another suspend function
8484
```
8585

86-
这是因为 [delay] 是一个特别的 _暂停函数_ ,它不会造成线程阻塞,但是 _暂停_<!--
86+
这是因为 [delay] 是一个特别的 _挂起函数_它不会造成线程阻塞,但是 _挂起_<!--
8787
-->函数只能在协程中使用.
8888

8989
### 桥接阻塞和非阻塞的世界
@@ -151,7 +151,7 @@ World!
151151
这里的 `runBlocking<Unit> { ... }` 作为一个适配器被用来启动最高优先级的主协程。
152152
我们明确的声明 `Unit` 为返回值类型,因为Kotlin中的`main`函数返回`Unit`类型。
153153

154-
这也是一种使用暂停函数来实现单元测试的方法
154+
这也是一种使用挂起函数来实现单元测试的方法
155155

156156
<!--- INCLUDE
157157
import kotlinx.coroutines.*
@@ -163,7 +163,7 @@ import kotlinx.coroutines.*
163163
class MyTest {
164164
@Test
165165
fun testMySuspendingFunction() = runBlocking<Unit> {
166-
// 这里我们可以使用暂停函数来实现任何我们喜欢的断言风格
166+
// 这里我们可以使用挂起函数来实现任何我们喜欢的断言风格
167167
}
168168
}
169169
```
@@ -294,8 +294,8 @@ Coroutine scope is over
294294

295295
让我们在 `launch { ... }` 中提取代码块并分离到另一个函数中. 当你
296296
在这段代码上展示"提取函数"函数的时候, 你的到了一个新的函数并用 `suspend` 修饰.
297-
这是你的第一个 _暂停函数_ 。暂停函数可以像一个普通的函数一样使用内部协程,但是它们拥有一些额外的特性,反过来说,
298-
使用其它的暂停函数, 比如这个例子中的 `delay`,可以使协程暂停执行。
297+
这是你的第一个 _挂起函数_ 。挂起函数可以像一个普通的函数一样使用内部协程,但是它们拥有一些额外的特性,反过来说,
298+
使用其它的挂起函数, 比如这个例子中的 `delay`,可以使协程暂停执行。
299299

300300
<div class="sample" markdown="1" theme="idea" data-min-compiler-version="1.3">
301301

@@ -307,7 +307,7 @@ fun main() = runBlocking {
307307
println("Hello,")
308308
}
309309

310-
// 你的第一个暂停函数
310+
// 你的第一个挂起函数
311311
suspend fun doWorld() {
312312
delay(1000L)
313313
println("World!")

0 commit comments

Comments
 (0)