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

Use interruptGuard in VThreadScheduler #37

Merged
merged 6 commits into from
Jan 24, 2024

Conversation

m8nmueller
Copy link
Contributor

A simple solution to this double scheduling. Allocate AtomicBoolean vs a new virtual thread.

Happy New Year! 🎉

@@ -13,11 +14,14 @@ object VThreadScheduler extends Scheduler:
override def execute(body: Runnable): Unit = VTFactory.newThread(body)

override def schedule(delay: FiniteDuration, body: Runnable): Cancellable =
val interruptGuard = AtomicBoolean(true) // to avoid interrupting the body
Copy link
Contributor

Choose a reason for hiding this comment

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

Great but use varHandle to reduce memory usage?

Copy link
Contributor

Choose a reason for hiding this comment

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

@He-Pin can you elaborate?

Copy link
Contributor

Choose a reason for hiding this comment

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

Like atomic interger field updater, which can reduce the 4byte ref of the object wrapper.

@natsukagami
Copy link
Contributor

@m8nmueller @He-Pin I implemented the VarHandle approach, please have a look.

He-Pin

This comment was marked as outdated.

Copy link
Contributor

@He-Pin He-Pin left a comment

Choose a reason for hiding this comment

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

I just commented, @natsukagami

Copy link
Contributor

@He-Pin He-Pin left a comment

Choose a reason for hiding this comment

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

lgtm, maybe I can try it with pekko some day:)

@natsukagami natsukagami merged commit bb078a1 into lampepfl:main Jan 24, 2024
3 checks passed
@m8nmueller m8nmueller deleted the vthread-schedule-abool branch April 15, 2024 09:52
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.

3 participants