Skip to content

[Overlay/Queue]: Allow setting an optional value in setSpecific #172

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

Merged
merged 1 commit into from
Jun 4, 2017

Conversation

karwa
Copy link

@karwa karwa commented Sep 19, 2016

Otherwise you can never clear anything you set

@MadCoder
Copy link
Contributor

that is fairly reasonable but isn't this ABI breaking? @mwwa please review wrt this, I agree the patch makes sense and is useful.

@mwwa
Copy link
Contributor

mwwa commented Sep 20, 2016

At this point I think this would need to be introduced as clearSpecific<T>(key:) so that we don't change the signature of setSpecific<T>(key:value:)

@karwa
Copy link
Author

karwa commented Sep 20, 2016

Urgh, it's disappointing that we're at that stage so early that we have to introduce new functions to patch flaws in existing ones.

Alternatively, we could add a DispatchSpecific subscript on DidpatchQueue which allows setting nil (IIRC we can have generic subscripts, but I may be wrong)

@karwa
Copy link
Author

karwa commented Sep 21, 2016

What I mean to say by that is: I wasn't aware binary compatibility was a concern for Swift 3. That's supposed to be the focus of Swift 4 stage 1, as I understand it.

@mwwa
Copy link
Contributor

mwwa commented Sep 21, 2016

It's not a binary compatibility issue, it's a source compatibility problem if people have to change the signatures of their existing uses in order to be able to compile.

@karwa
Copy link
Author

karwa commented Oct 11, 2016

@mwwa Is it actually source-breaking? Swift automatically promotes types to their optionals, so any code which used the non-optional setter will continue to compile.

Also, this is technically a memory leak. I just encountered it in my app - thousands of DispatchSpecificKey allocations being left behind because something in Dispatch is retaining them (and can't be cleared). Each is 32 bytes so you lose 1K from just 32 of them. This is in a reasonably memory-constrained environment.

@karwa
Copy link
Author

karwa commented Oct 17, 2016

@MadCoder can we make any progress on this? As I mentioned it shouldn't be source-breaking (although the symbol would change, so it is ABI-breaking)

@mwwa
Copy link
Contributor

mwwa commented Oct 17, 2016

Good point with the source compat. That looks ok then. This needs to be cloned for the mainline Dispatch overlay too (in the apple/swift repo).

@swift-ci please test.

@karwa
Copy link
Author

karwa commented Oct 17, 2016

Failure is unrelated. It's the Foundation NSURLSession one that crops up from time to time.

'
11:04:00.845
Test Case 'TestURLSession.test_dataTaskWithURL' started at 11:04:00.845
fatal error: Transfer completed, but there's no currect request.: file Foundation/NSURLSession/NSURLSessionTask.swift, line 794
/home/buildnode/jenkins/workspace/swift-corelibs-libdispatch-PR-Linux/swift/utils/build-script-impl: line 249: 9670 Illegal instruction (core dumped) "$@"
/home/buildnode/jenkins/workspace/swift-corelibs-libdispatch-PR-Linux/swift/utils/build-script: fatal error: command terminated with a non-zero exit status 132, aborting
Build step 'Execute shell' marked build as failure
'

@karwa
Copy link
Author

karwa commented Oct 23, 2016

I think the Foundation test has been fixed now. Can we run it again?

@parkera
Copy link
Contributor

parkera commented Oct 24, 2016

@swift-ci please test

@karwa
Copy link
Author

karwa commented Oct 24, 2016

huh, ¯_(ツ)_/¯

Foundation contains a grand total of one (1) DispatchSpecificKey, on NSOperation. It's never referenced anywhere else, and NSOperation is never referenced from any other types in Foundation. So I'm pretty sure this change didn't break anything.

@karwa
Copy link
Author

karwa commented Oct 30, 2016

I don't know why the test is failing (some assertion failure in kqueue), but I'm sure this patch has nothing to do with it.

@karwa
Copy link
Author

karwa commented Jan 10, 2017

Can we test this again? I'd like to try get it in for the 3.1 branch date

@karwa
Copy link
Author

karwa commented Feb 13, 2017

Ping? This has already been merged in the Darwin SDK overlay.

@das
Copy link
Contributor

das commented Jun 4, 2017

@swift-ci please test

@das
Copy link
Contributor

das commented Jun 4, 2017

tests pass, so lets cleanup this discrepancy for 4.0

@das das merged commit dc1857c into swiftlang:master Jun 4, 2017
@das das unassigned mwwa Jun 4, 2017
das added a commit that referenced this pull request Jul 31, 2017
[Overlay/Queue]: Allow setting an optional  value in setSpecific

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
@das das removed the darwin pending label Aug 1, 2017
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.

6 participants