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

Implement prototype of flexible hook handler class #74

Merged
merged 11 commits into from
Sep 18, 2016

Conversation

syucream
Copy link
Owner

@syucream syucream commented Sep 7, 2016

#36

  • Separate logic related to thread shared/local data.
  • Add a new class, load handler and insert appropriate hook plugins.
  • Refactoring.

- [ ] Modify unit test code will be fixed by #75

@coveralls
Copy link

Coverage Status

Coverage decreased (-51.7%) to 0.0% when pulling bf60a27 on feature/hook_prototype into f4b525a on master.

@syucream
Copy link
Owner Author

syucream commented Sep 7, 2016

Idea notes

Requirements

  • low memory consumption
  • safely memory access

Idea

  • Enforce users to create their handler class(or module?). For example:
module MyEventHandler
  def on_send_request_hdr
    ...
  end
end
  • Generate new obj of the class from current thread-local mrb_state.
    • Avoid to create new mrb_state.
    • Is it unsafely access?
  • To avoid unexpected GC, I must mark the new obj.
    • Stop GC temporarily by calling mrb_gc_register()
    • And restart GC by calling mrb_gc_unregister()
    • It has a risk of missing mrb_gc_unregister() so I should take RAII approach, for example using shared_ptr.
  • Insert a new TransactionPlugin registers hooks and has hook handler functions.
    • Execute the obj by calling mrb_funcall_*()

@syucream
Copy link
Owner Author

syucream commented Sep 8, 2016

progress

Tried to fix #74 (comment) by c753613.

new issue

  • Detect unusable class/method usage.
    • For example, ATS::echo is unavailable at late hook.
    • Should these calling raise an exception?

@coveralls
Copy link

Coverage Status

Coverage decreased (-51.7%) to 0.0% when pulling 98dacd8 on feature/hook_prototype into f4b525a on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-51.7%) to 0.0% when pulling 98dacd8 on feature/hook_prototype into f4b525a on master.

@syucream
Copy link
Owner Author

To detect unusable class/method usage, plugin must pass hook timing to the transaction because atscppapi::Transaction doesn't have hook info API.

@coveralls
Copy link

Coverage Status

Coverage decreased (-51.7%) to 0.0% when pulling 42bf9bb on feature/hook_prototype into f4b525a on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-51.7%) to 0.0% when pulling 54f187d on feature/hook_prototype into f4b525a on master.

@syucream
Copy link
Owner Author

TSMrubyValue implemented at c753613 has non-thread-safe function.
At a5dd106, I try implementing an another approach.

@coveralls
Copy link

Coverage Status

Coverage decreased (-51.7%) to 0.0% when pulling a5dd106 on feature/hook_prototype into f4b525a on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-51.7%) to 0.0% when pulling 5ba68e8 on feature/hook_prototype into f4b525a on master.

@syucream
Copy link
Owner Author

Modify unit test code

Its a big task. I fix it as another issue.
#75

@coveralls
Copy link

Coverage Status

Coverage decreased (-51.7%) to 0.0% when pulling 706c841 on feature/hook_prototype into f4b525a on master.

@syucream syucream changed the title [WIP] Implement prototype of flexible hook handler class Implement prototype of flexible hook handler class Sep 18, 2016
@coveralls
Copy link

Coverage Status

Coverage decreased (-51.7%) to 0.0% when pulling a999df4 on feature/hook_prototype into f4b525a on master.

@syucream syucream merged commit 1078d3d into master Sep 18, 2016
@syucream syucream deleted the feature/hook_prototype branch September 18, 2016 03:28
@syucream syucream mentioned this pull request Sep 21, 2016
3 tasks
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