Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BankAccount {
- int balance_;
- public:
- void Deposit(int amount, StrictLock<BankAccount>&) {
- // Externally locked
- balance_ += amount;
- }
- void Deposit(int amount) {
- Lock guard(*this); // Internally locked
- Deposit(amount, guard);
- }
- void Withdraw(int amount, StrictLock<BankAccount>&) {
- // Externally locked
- balance_ -= amount;
- }
- void Withdraw(int amount) {
- Lock guard(*this); // Internally locked
- Withdraw(amount, guard);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement