On Wed, 11 Oct 2017 13:57:08 -0400, Steven Schveighoffer wrote:

On 10/11/17 1:50 PM, Clinton D Skakun wrote:

void getUser(req, res) {
auto db = pool.lock()

db.query(...)

req.writeBody...
}

What happens when getUser is called but the request is cancelled halfway through before the query finishes?

Is there ever a time when the lock will never be released?

Unlikely. The lock is handled automatically via reference counting. So
the unlock will be done as the destructor for db is called exiting the
scope. This happens even if an exception is thrown.

-Steve

Thanks Steve, do you know if there's a straightforward method to do a writeln once a connection is unlocked?