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

locks and rlocks use destructors #18640

Closed
wants to merge 9 commits into from
Closed

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Aug 3, 2021

This PR wants to adding destructors for Lock/Rlock/Cond for ARC/ORC and does less harm. It turns deinitLock, deinitRlock, deinitCond into a no-op and deprecates them. Then it also adds destructors for these objects.

Same transition method could be applied to Stream, File, socket or so if it were fine. It should cause less harm and less breaking changes. Then we don't need to close File, Stream manually.

lib/core/locks.nim Outdated Show resolved Hide resolved
lib/core/locks.nim Outdated Show resolved Hide resolved
lib/core/locks.nim Outdated Show resolved Hide resolved
lib/core/locks.nim Outdated Show resolved Hide resolved
lib/core/rlocks.nim Outdated Show resolved Hide resolved
lib/core/locks.nim Outdated Show resolved Hide resolved
lib/core/locks.nim Outdated Show resolved Hide resolved
lib/core/rlocks.nim Outdated Show resolved Hide resolved
lib/core/rlocks.nim Outdated Show resolved Hide resolved
tests/stdlib/trlocks.nim Outdated Show resolved Hide resolved
lib/core/locks.nim Outdated Show resolved Hide resolved
lib/core/locks.nim Outdated Show resolved Hide resolved
lib/core/locks.nim Outdated Show resolved Hide resolved
lib/core/rlocks.nim Outdated Show resolved Hide resolved
lib/core/rlocks.nim Outdated Show resolved Hide resolved
initSysLock(lock.lock)

when useOrcArc:
proc `=sink`*(x: var Lock, y: Lock) {.error.}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ringabout
Copy link
Member Author

The cause of CI failure seemed to be this: arc + threads + tlsEmulation

#18644

I will look into it some days later(for instance duplicate the test in the tests/stdlib directory instead).

@ringabout ringabout changed the title [wip]locks and rlock use destructors locks and rlock use destructors Aug 29, 2021
@ringabout ringabout changed the title locks and rlock use destructors locks and rlocks use destructors Aug 29, 2021
@ringabout
Copy link
Member Author

With this PR, locks and rlocks module can switch to destructors gradually. However it causes inconsistence between arc and refc implementation, users need to implement separate codes. Or it can be hidden under the umbrella of nimPreviewX.

@ringabout ringabout closed this Aug 30, 2021
@ringabout ringabout reopened this Aug 30, 2021
@ringabout ringabout closed this Sep 22, 2021
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

Successfully merging this pull request may close these issues.

2 participants