Skip to content

Add ThreadLocal.isPresent and ThreadLocal.ensurePresent methods #1043

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

Merged
merged 2 commits into from
Mar 22, 2019

Conversation

qwwdfsad
Copy link
Collaborator

Fixes #1028

@qwwdfsad qwwdfsad requested a review from elizarov March 14, 2019 10:20
* }
* ```
*/
public suspend fun ThreadLocal<*>.isPresent(): Boolean = coroutineContext[ThreadLocalKey(this)] != null
Copy link
Contributor

Choose a reason for hiding this comment

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

Make it inline so that suspension point is not generated at its use-site.

* }
* ```
*/
public suspend fun ThreadLocal<*>.ensurePresent(): Unit = check(isPresent()) { "ThreadLocal $this is missing from context $coroutineContext" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Make it inline so that suspension point is not generated at its use-site.

…generating state machine where it is not necessary
@qwwdfsad qwwdfsad merged commit 0355b2c into develop Mar 22, 2019
@qwwdfsad qwwdfsad deleted the tl-check branch March 22, 2019 13:02
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