简体   繁体   English

呼叫“旋转”是什么意思

[英]What does it mean for a call to “spin”

What does it mean for a function call to "spin?" 函数调用“旋转”是什么意思? Is it the same as blocking? 与封锁相同吗?

This is the context I'm referring to: 这是我所指的上下文:

/*
     * Obtain a free channel
     * This call spins till a free channel is obtained
     */
    chNum = _getFreeChannel(&tccNum);

Thanks. 谢谢。

To loop, basically. 基本上是循环。 What a spinning function does is busy-waiting with a loop. 旋转功能的作用是忙于循环。

A spin is a concurrency technique. 自旋是一种并发技术。 Essentially the function loops until the desired condition is met. 本质上,该功能会循环直到满足所需条件。

It can be computationally expensive if the spin time is large, but can be preferable to wait and notification idioms (for which there is a set-up overhead) if the expected spin time is very small with low variance. 如果旋转时间很大,则在计算上可能会很昂贵,但是如果预期的旋转时间非常小且方差低,则等待并通知惯用语(为此存在设置开销)可能更可取。

When a Function spins, it is typically checking some condition (like a variable) over and over in a tight loop until it becomes some interesting value. 当一个函数旋转时,它通常会紧密地反复检查某些条件(例如变量),直到它变成一些有趣的值为止。 It then continues running once the condition is met. 一旦满足条件,它将继续运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM