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

Feature to add dynamically new data into the global context #33

Merged
merged 2 commits into from
Jul 2, 2013

Conversation

slemiere
Copy link
Contributor

Hello,

I needed for my use case to add dynamically data to the global context so I did something like this:

Scrolls.global_context(Scrolls.global_context.merge(process_name: @process_name))

But it wasn't thread safe and I felt like it could be a pretty common use case so I added the functionality directly into Scrolls with the methods add_global_context, let me know if you think it could be useful and if I should change it.

Thanks !

@asenchi
Copy link
Owner

asenchi commented Jun 15, 2013

Actually, global_context is stored as an atomic object, so I'm pretty sure it should be thread safe. My initial impression is that an add_global_context would be useful, however, I don't think we need the lock you have here. Look in set_global_context for how the atomic object is used.

Like the idea though.

@slemiere
Copy link
Contributor Author

It is indeed a lot better using the #update method of Atomic, I have updated my pull request accordingly. Let me know what you think.

asenchi added a commit that referenced this pull request Jul 2, 2013
Feature to add dynamically new data into the global context
@asenchi asenchi merged commit a398adc into asenchi:master Jul 2, 2013
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.

None yet

2 participants