Skip to content

Thread detach hook for Java JNI on Android #250

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

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
Implemented getter
  • Loading branch information
johnno1962 committed May 27, 2017
commit 10ea8cf1a6b6a63ca24707d06a71b3d760a8503a
2 changes: 2 additions & 0 deletions private/queue_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ dispatch_async_enforce_qos_class_f(dispatch_queue_t queue,
*/
DISPATCH_EXPORT
void _dispatch_set_detach_callback( void (*callback)(void) );
DISPATCH_EXPORT
void (*_dispatch_get_detach_callback(void))(void);
#endif

__END_DECLS
Expand Down
3 changes: 3 additions & 0 deletions src/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,9 @@ static void (*_dispatch_thread_detach_callback)(void);
void _dispatch_set_detach_callback( void (*callback)(void) ) {
_dispatch_thread_detach_callback = callback;
}
void (*_dispatch_get_detach_callback(void))(void) {
return _dispatch_thread_detach_callback;
}
#endif

void
Expand Down
5 changes: 4 additions & 1 deletion src/swift/Queue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,13 @@ public extension DispatchQueue {
#if os(Android)
@_silgen_name("_dispatch_set_detach_callback")
private static func _dispatch_set_detach_callback( _ callback: (@convention(c) () -> Void)? )
@_silgen_name("_dispatch_get_detach_callback")
private static func _dispatch_get_detach_callback() -> (@convention(c) () -> Void)?

public static var threadDetachCallback: (@convention(c) () -> Void)? {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think only a one-way setter should be exposed. having a getter makes the interface un-necessarily ugly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the potiners. It helps me zero in on something you’re happy with. Changed pushed.

get {
return nil
return _dispatch_get_detach_callback()

}
set(newValue) {
_dispatch_set_detach_callback( newValue )
Expand Down