[GODRIVER-75] Use defer for mutex unlocking Created: 06/Sep/17  Updated: 28/Oct/23  Resolved: 25/Oct/17

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 0.0.1

Type: Task Priority: Major - P3
Reporter: David Golden Assignee: Samuel Rossi (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Much of the monitoring code I've looked at relies on manual mutex unlocking. This is not generally idiomatic Go (except in hot code paths) and leads to errors, as shown in GODRIVER-74. Until we know there's a performance problem caused by defer, avoiding defer is premature optimization that increases the likelihood of bugs.

We should change all unlocking to use defer when possible. (N.B. For whoever does this work: note that it's not possible inside a for loop, as defer is function scoped, not loop scoped.)



 Comments   
Comment by Githook User [ 10/Nov/17 ]

Author:

{'name': 'Saghm Rossi', 'username': 'saghm', 'email': 'saghmrossi@gmail.com'}

Message: GODRIVER-75 Use defer for mutex unlocking
Branch: GODRIVER-33
https://github.com/10gen/mongo-go-driver/commit/f06f1a772cf5f212bdf0f3bef46bf8bea0deeb4d

Comment by Samuel Rossi (Inactive) [ 25/Oct/17 ]

Git commit: https://github.com/10gen/mongo-go-driver/commit/f06f1a772cf5f212bdf0f3bef46bf8bea0deeb4d

Generated at Thu Feb 08 08:33:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.