| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Mutex semaphores |
MS> so (better):
MS> class RequestMutex
MS> {
MS> public:
MS> RequestMutex(Mutex & mutex) : mutex(mutex) { mutex.request();}
MS> ~RequestMutex() { mutex.release();}
MS> private:
MS> Mutex mutex;
MS> };
MS> function()
MS> {
MS> RequestMutex request(mutex);
MS> call someone();
MS> return rc;
MS> };
MS> now, request is a local object, and when an exception is thrown, ALL
MS> local (stack based) objects get destroyed! so, ~RequestMutex is called and
MS> the sema4 is released.
Any ideas on how to do this in plain C?
(sorry for excess quoting, mr.moderator)
---
* Origin: Life = Computer XOR Girlfriend (2:229/229.5)SEEN-BY: 50/99 270/101 620/243 625/160 711/401 409 410 413 430 808 809 934 SEEN-BY: 711/955 712/407 515 624 628 713/317 800/1 @PATH: 229/0 270/101 712/515 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.