summaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
authorCarl Baldwin <carl@ecbaldwin.net>2019-10-11 13:11:44 -0600
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-10-15 20:21:18 +0900
commit65929fe5245f715322286f683cbcf3d15699e8b4 (patch)
treeecc0962196b84e1d43f15a5b8b1c65a70b710c85 /docs
parentea87564b5b5d332ab48b6619c4a365559111e2c9 (diff)
Keep Lock and defer Unlock together
The best way to ensure that a lock will always get unlocked is to defer the unlock immediately after locking. Otherwise, adding a return statement in the middle somewhere *could* result in forgetting to release the lock. One of these two cases has that. This technique uses an anonymous function/closure within the larger method to confine the scope of the lock and ensure that it will be unlocked in every case.
Diffstat (limited to 'docs')
0 files changed, 0 insertions, 0 deletions