c - Calling a void function inside loop control condtion -


I would like to write a loop with the following pattern, where is the return type of spin_lock Zero :

  while (workers available) & amp; Spin_lock (workQueueLock) & amp; (WorkQueue) || spin_unlock (workQueueLock))) ... ... spin_unlock (functional lock); // no need for lock-in, as long as working).  

Logic:

  • I lock the lock as much as possible I want to keep it and no is needed for the workers ()
  • I know that I can write a function int f () {spin_lock (workQueueLock); Come back! List_empty (workQueue) || || Spin_unlock (; workQueueLock);} , though I think that should be a better way
  • I understand that & amp; Amp; Since zero since & amp; Amp; And two operands are not required
  • I tried , and it will not compile, except that I am not
< P> Question: Is there any way to get it without any extra procedure and without any speed without , inside the loop body? Control logic (i.e. spin_lock ( WorkQueueLock; if (list_empty (workQueue)) {} spin_unlock (workQueueLock); break;} )?

If you really want to do this, you can use , You can use it, it will only leave all evaluation left operators (workers available) and (spin_lock (workQueueLock), 1) & amp; Amp; Amp;! (List) (workQueue) || Spin_unlock (workQueueLock))

  code> 

But in my opinion, you should write a function, it is clear.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -