Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about calling mem::drop() manually #3

Closed
katyo opened this issue Nov 11, 2020 · 1 comment
Closed

Question about calling mem::drop() manually #3

katyo opened this issue Nov 11, 2020 · 1 comment

Comments

@katyo
Copy link
Collaborator

katyo commented Nov 11, 2020

As I see you call mem::drop to drop locking guards like here:

rquickjs/src/runtime.rs

Lines 110 to 115 in 14e5df0

pub fn set_memory_limit(&self, limit: usize) {
let guard = self.inner.lock();
let limit = limit as qjs::size_t;
unsafe { qjs::JS_SetMemoryLimit(guard.rt, limit) }
mem::drop(guard);
}

What the actual reason to do it in that manner?

@katyo
Copy link
Collaborator Author

katyo commented Nov 12, 2020

If I understand correctly this helps avoid dropping guard druring ffi function call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant