但是对于某个变量的条件产生的模糊性是应该限制的。
But ambiguity need not be restricted to conditions of one variable.
每一个条件表达了各种变量之间的关系是正确的还是错误的。
Each condition expresses a relationship among variables that must be resolvable as true or false.
不过,每个条件变量都应该伴有一个互斥。
还要注意,两个条件变量使用相同的互斥锁。
采用这种方法,可以模拟各种条件、事件发生次序和变量。
With this approach, you could simulate the various conditions, sequence, and variables.
接下来,读线程需要确保(这是第二个检查)它等待条件变量的时间不超过指定的超时时间。
Next, the reader thread needs to ensure (and this is the second check you perform) that it does not wait on the condition variable any more than the specified timeout period.
另外,您也可以不使用变量,如清单6中所示,因为条件很简单。
Alternatively, you can drop the variable, as in Listing 6, because the condition is so simple.
线程模块提供了许多同步原语,包括信号量、条件变量、事件和锁。
The threading module does provide many synchronization primatives, including semaphores, condition variables, events, and locks.
当队列是空的时候,读线程现在并不抛出异常,而是在条件变量上阻塞自身。
Instead of throwing an exception when the queue is empty, the reader thread now blocks itself on the condition variable.
为解决此缺憾,我使用POSIX条件变量模拟同步原语,并在一系列文章中对此进行了概述。
To work around this omission, I use the POSIX condition variable emulations synchronization primitives, which are outlined in the series of articles.
它不但要求仔细分析在什么条件可以对变量进行读写,而且要求仔细分析其它类能如何使用某个类。
It requires a careful analysis of not only the conditions under which variables will be read or written, but also of how the class might be used by other classes.
当然,您还可以创建一个全局的脚本,并使用条件和环境变量HOSTNAME以选择合适的设置。
Of course, you can also create a global script and use conditionals and the environment variable HOSTNAME to choose the appropriate settings.
您可以方便地创建变量、循环,使用条件和创建函数。
You won't have any trouble creating variables, looping, using conditionals, and creating functions.
对于清单13和清单14,要注意的第一点是,这个阻塞队列有两个条件变量而不是一个。
The first thing of note in Listing 13 and Listing 14 is that there are two condition variables instead of the one that the blocking queue had.
条件变量让开发者能够实现一个条件,在这个条件下线程执行然后被阻塞。
A condition variable enables developers to implement a condition in which a thread executes and then blocked.
然后检验选择项组合碎片的约束条件,确认余额大于金额变量。
Then the option combination fragment's guard condition is checked to verify the balance is greater then the amount variable.
条件中指定的变量必须在设置了断点的行中,否则表达式就没有什么意义!
The variables specified in the condition must be in scope at whatever line you set the breakpoint on, otherwise the expression wouldn't make sense!
因此,最后两个读线程都等待条件变量,互斥锁没有被锁住。
Therefore, at the end of it all, you now have two reader threads, both waiting on the condition variable, and the mutex is unlocked.
对象不变量则将特定条件运用于对象的状态上,确保其不会拥有非法的值。
Object invariants are used to enforce certain conditions on objects to make sure they don't obtain illegal values.
这个操作要消耗一定的时间,实际上,这个时间太长了,可能在进行这项操作的同时,线程所等待的条件变量的值在这期间已经改变了。
This may take some time. In fact, it may take so much time that the condition you were waiting for is no longer the case.
这正是POSIX条件变量能做的事!
That's precisely what POSIX condition variables can do for you!
它还允许您原子地(atomically)解除互斥的锁定,并等待条件变量,而不会有干涉其他线程的可能。
It also allows you to unlock the mutex and wait on the condition variable atomically, without the possible intervention of another thread.
push方法不依赖于任何条件变量,所以没有额外的等待。
Now, the push method doesn't depend on any condition variables, so no extra waiting there.
而且,条件可能随以下变量发生改变。
Furthermore, the conditions may be changed as according to these variables.
ClosureStylesheets让我们可以使用@if、@elseif和@else,从而基于某些变量的值来创建条件语句的分支。
Closure Stylesheets allows the use of @if, @elseif and @else in creating conditional branches based on the value of some variables.
这些例子演示scheme的一些关键特性,此外还演示了变量、条件和循环。
These examples illustrate variables, conditionals, and loops in addition to some of the key features of Scheme.
如果队列满了,写线程等待_ wcond条件变量;读线程在从队列中取出数据之后需要通知所有线程。
If the queue is full, the writer thread waits on the _wcond condition variable; the reader thread will need a notification to all threads after consuming data from the queue.
当不再使用条件变量时,应该调用pthread_cond_destroy释放它在初始化时分配的资源。
When you're done with a condition variable, you can release any resources allocated during initialization with a call to pthread_cond_destroy .
这么做会唤醒所有等待条件变量_ cond的读线程;读线程现在隐式地争夺互斥锁。
Doing so awakens all the reader threads that were waiting on the condition variable _cond; the reader threads now implicitly compete for the mutex lock as and when it is released.
这么做会唤醒所有等待条件变量_ cond的读线程;读线程现在隐式地争夺互斥锁。
Doing so awakens all the reader threads that were waiting on the condition variable _cond; the reader threads now implicitly compete for the mutex lock as and when it is released.
应用推荐