Obligatory "I ruined everything!" thread
#23
Pair of functions - not good, someone will forget the lock locked somewhere and no-one will find it. With RAII, someone could still forget the locking completely.
The point of an API is to be safe whoever wants to call whatever. Windows API, too, doesn't say "you need to lock the filesystem, only then you can call the FileOpen function", it does the locking in itself, when needed. That's the point of the entire API - hide the locking from the "users". In this case "users" = other programmers using that API.
Pity that we don't have C++11 yet, we could use lambda functions as the callbacks, and you'd be happy. But trust me, this is the best possible way.
Reply
Thanks given by:


Messages In This Thread
RE: Obligatory "I ruined everything!" thread - by xoft - 07-12-2012, 07:27 AM



Users browsing this thread: 1 Guest(s)