Skip to content

Comments

Implement Kernel#at_exit and Kernel.at_exit.#2363

Closed
take-cheeze wants to merge 1 commit intomruby:masterfrom
take-cheeze:proc_atexit
Closed

Implement Kernel#at_exit and Kernel.at_exit.#2363
take-cheeze wants to merge 1 commit intomruby:masterfrom
take-cheeze:proc_atexit

Conversation

@take-cheeze
Copy link
Contributor

atexit_stack's type will be mrb_value* and it will be marked on root_scan_phase().

@cremno
Copy link
Contributor

cremno commented Jun 5, 2014

Casting mrb_atexit_func to void * is undefined behavior in C and C++. However I doubt this will be a problem. On POSIX and Windows systems it's okay to do so.

Maybe it's preferable to:

  • replace mrb_atexit_func with mrb_func_t
  • change the data type of the stack to struct RProc *

@take-cheeze
Copy link
Contributor Author

@cremno You're right.
Seems like Kernel.at_exit proc stack should be stored to other place.

@take-cheeze take-cheeze closed this Jun 5, 2014
@matz
Copy link
Member

matz commented Jun 5, 2014

Do we really need it? I prefer explicit use of ensure clause.

@take-cheeze
Copy link
Contributor Author

@matz I think script only mrbgem require these feature since it can't use mrb_*_gem_final.

@matz
Copy link
Member

matz commented Jun 6, 2014

It should be quite rare case. As far as I know there's no gem using valid *_final yet.
If you really want finalization, you can always write C part. We don't have to spoil gem writers.

@take-cheeze
Copy link
Contributor Author

@matz I agree.
Making gem writer to write C finalizer is better.

@take-cheeze take-cheeze deleted the proc_atexit branch June 7, 2014 13:33
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