<div dir="ltr"><div class="gmail_default"><span class="gmail-im"><font face="garamond, serif"><div class="gmail_default">What is the type of self? If it is a class, try [unowned self].</div><div class="gmail_default"><br></div><div class="gmail_default">Zhaoxin</div></font></span><span class="gmail-im"><div><font face="georgia, serif"><br></font></div><div><font face="georgia, serif"><br></font></div><div style="font-family:georgia,serif"><font face="monospace, monospace"><br></font></div><div style="font-family:georgia,serif"><font face="monospace, monospace"><br></font></div><div style="font-family:georgia,serif"><font face="monospace, monospace"><br></font></div></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 16, 2016 at 4:33 PM, Rien via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">How about using:<br>
<br>
UnsafeMutablePointer<<wbr>TypeOfSelf><br>
<br>
?<br>
<br>
Regards,<br>
Rien<br>
<br>
Site: <a href="http://balancingrock.nl" rel="noreferrer" target="_blank">http://balancingrock.nl</a><br>
Blog: <a href="http://swiftrien.blogspot.com" rel="noreferrer" target="_blank">http://swiftrien.blogspot.com</a><br>
Github: <a href="http://github.com/Swiftrien" rel="noreferrer" target="_blank">http://github.com/Swiftrien</a><br>
Project: <a href="http://swiftfire.nl" rel="noreferrer" target="_blank">http://swiftfire.nl</a><br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
> On 16 Dec 2016, at 09:10, Richard Wei via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br>
><br>
> Capturing makes it immutable, which unfortunately can't solve this problem.<br>
><br>
> -Richard<br>
><br>
>> On Dec 16, 2016, at 02:05, Zhao Xin <<a href="mailto:owenzx@gmail.com">owenzx@gmail.com</a>> wrote:<br>
>><br>
>> I did not test the code. But if you cannot implicitly capture a mutating self, you should do it explicitly, right?<br>
>><br>
>> let blockSize = min(512, count)<br>
>> let blockCount = (count+blockSize-1)/blockSize<br>
>> device.sync { [self] () -> () in // Launch CUDA kernel<br>
>> try! fill<<<(blockSize, blockCount)>>>[<br>
>> .pointer(to: &self), .value(value), .value(Int64(count))<br>
>> ]<br>
>> }<br>
>><br>
>> Hope above code works.<br>
>><br>
>> Zhaoxin<br>
>><br>
>> On Fri, Dec 16, 2016 at 3:46 PM, Richard Wei via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br>
>> Hi,<br>
>><br>
>> Swift 3.0.2 seems to have broken my code due to mutating self capture. But I have to pass inout self to the closure. Any workaround?<br>
>><br>
>> let blockSize = min(512, count)<br>
>> let blockCount = (count+blockSize-1)/blockSize<br>
>> device.sync { // Launch CUDA kernel<br>
>> try! fill<<<(blockSize, blockCount)>>>[<br>
>> .pointer(to: &self), .value(value), .value(Int64(count))<br>
>> ]<br>
>> }<br>
>><br>
>> <PastedGraphic-1.png><br>
>><br>
>> -Richard<br>
>><br>
>> ______________________________<wbr>_________________<br>
>> swift-users mailing list<br>
>> <a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
>> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
>><br>
>><br>
><br>
> ______________________________<wbr>_________________<br>
> swift-users mailing list<br>
> <a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br>
______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
</div></div></blockquote></div><br></div>