07.03.2013 Views

Multithreading Multi-Threaded Programming

Multithreading Multi-Threaded Programming

Multithreading Multi-Threaded Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C<strong>Multi</strong>Lock<br />

} This class allows you to block, or wait, on up to 64<br />

synchornization objects at once. You create an array of<br />

references to the objects, and pass this to the<br />

constructor. In addition, you can specify whether you<br />

want it to unblock when one object unlocks, or when all<br />

of them do.<br />

CCriticalSection cs;<br />

CMutex mu;<br />

CEvent ev;<br />

CSemaphore sem[3];<br />

...<br />

CSynObject* objects[6]={&cs, &mu, &ev, &sem[0], &sem[1], &sem[2]};<br />

C<strong>Multi</strong>Lock mlock(objects,6);<br />

int result=mlock.Lock(INFINITE, FALSE);<br />

...<br />

50<br />

Advanced Windows Network <strong>Programming</strong><br />

11/11/12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!