Tornado 6.5 Documentation
You can also use IOLoop.run_in_executor to asynchronously run a blocking function on another thread, but note that the function passed to run_in_executor should avoid referencing any Tornado objects. run_in_executor 1 Blocking A function blocks when it waits for something to happen before returning. A function may block for many reasons: network I/O, disk I/O, mutexes, etc. In fact, every function blocks, at least design use hundreds of milliseconds of CPU time, far more than a typical network or disk access). A function can be blocking in some respects and non-blocking in others. In the context of Tornado we generally0 码力 | 272 页 | 1.12 MB | 2 月前3Tornado 6.5 Documentation
You can also use IOLoop.run_in_executor to asynchronously run a blocking function on another thread, but note that the function passed to run_in_executor should avoid referencing any Tornado objects. run_in_executor Blocking A function blocks when it waits for something to happen before returning. A function may block for many reasons: network I/O, disk I/O, mutexes, etc. In fact, every function blocks, at least design use hundreds of milliseconds of CPU time, far more than a typical network or disk access). A function can be blocking in some respects and non-blocking in others. In the context of Tornado we generally0 码力 | 437 页 | 405.14 KB | 2 月前3Rust 程序设计语言 简体中文版 1.85.0
的新实例。String 是一个标准库提供的字 符串类型,它是 UTF-8 编码的可增长文本块。 ::new 那一行的 :: 语法表明 new 是 String 类型的一个 关联函数(associated function)。关 联函数是针对某个类型实现的函数,在这个例子中是 String。这个 new 函数创建了一个新的 空字符串。你会发现许多类型上都有一个 new 函数,因为这是为某种类型创建新值的常用函数 another_function(); } fn another_function() { println!("Another function."); } 我们在 Rust 中通过输入 fn 后面跟着函数名和一对圆括号来定义函数。大括号告诉编译器哪 里是函数体的开始和结尾。 可以使用函数名后跟圆括号来调用我们定义过的任意函数。因为程序中已定义 another_function 函数,所以可以在 函数,所以可以在 main 函数中调用它。注意,源码中 another_function 定 义在 main 函数 之后;也可以定义在之前。Rust 不关心函数定义所在的位置,只要函数被调用 时出现在调用之处可见的作用域内就行。 让我们新建一个叫做 functions 的二进制项目来进一步探索函数。将上面的 another_function 例子写入 src/main.rs 中并运行。你应该会看到如下输出:0 码力 | 562 页 | 3.23 MB | 9 天前3
共 3 条
- 1