<div class="socmaildefaultfont" dir="ltr" style="font-family:Arial;font-size:10.5pt" ><div dir="ltr" >Dave</div>
<div dir="ltr" >&nbsp;</div>
<div dir="ltr" >I am running the test-case on Mac but with the OpenSource Foundation source code. Just FYI if you missed the earlier conversation.</div>
<div dir="ltr" >&nbsp;</div>
<div dir="ltr" >-Mamatha</div>
<div dir="ltr" >&nbsp;</div>
<blockquote data-history-content-modified="1" data-history-expanded="1" dir="ltr" style="border-left:solid #aaaaaa 2px; margin-left:5px; padding-left:5px; direction:ltr; margin-right:0px" >----- Original message -----<br>From: David P Grove/Watson/IBM<br>To: Philippe Hausler &lt;phausler@apple.com&gt;<br>Cc: Mamatha Busi &lt;mamabusi@in.ibm.com&gt;, swift-corelibs-dev@swift.org<br>Subject: Re: [swift-corelibs-dev] Setting property "maxConcurrentOperationCount = 1" of NSOperation fails to execute operations using OpenSource Foundation.<br>Date: Fri, May 6, 2016 8:12 PM<br>&nbsp;<br><font size="2" >I think the intuition about the dispatch overlay being the problem on Linux is right on. &nbsp;We may have to hack around the problem on the Foundation side until an improved overlay is available to use.</font><br><br><font size="2" >--dave</font><br><br><br><img alt="Inactive hide details for Philippe Hausler via swift-corelibs-dev ---05/06/2016 09:43:06 AM---I have a feeling this is associat" border="0" height="16" src="/icons/graycol.gif" width="16" ><font color="#424282" size="2" >Philippe Hausler via swift-corelibs-dev ---05/06/2016 09:43:06 AM---I have a feeling this is associated with the changes for IUO types that recently landed. I am very w</font><br><br><font color="#5F5F5F" size="2" >From: </font><font size="2" >Philippe Hausler via swift-corelibs-dev &lt;swift-corelibs-dev@swift.org&gt;</font><br><font color="#5F5F5F" size="2" >To: </font><font size="2" >Mamatha Busi &lt;mamabusi@in.ibm.com&gt;</font><br><font color="#5F5F5F" size="2" >Cc: </font><font size="2" >swift-corelibs-dev@swift.org</font><br><font color="#5F5F5F" size="2" >Date: </font><font size="2" >05/06/2016 09:43 AM</font><br><font color="#5F5F5F" size="2" >Subject: </font><font size="2" >Re: [swift-corelibs-dev] Setting property "maxConcurrentOperationCount = 1" of NSOperation fails to execute operations using OpenSource Foundation.</font><br><font color="#5F5F5F" size="2" >Sent by: </font><font size="2" >swift-corelibs-dev-bounces@swift.org</font>
<hr align="left" size="2" style="color:#8091A5; " width="100%" ><br><br><br><font size="3" >I have a feeling this is associated with the changes for IUO types that recently landed. I am very worried that this actually could happen on Darwin targets as well. Perhaps it is the swift overlay for dispatch that is correcting the failure on Darwin and the dispatch on Linux is missing that annotation. Worth looking into.<br><br>Sent from my iPhone</font><br><br><font size="3" >On May 6, 2016, at 12:16 AM, Mamatha Busi &lt;</font><a href="mailto:mamabusi@in.ibm.com" target="_blank" ><u><font color="#0000FF" size="3" >mamabusi@in.ibm.com</font></u></a><font size="3" >&gt;&nbsp;wrote:</font>
<ul style="padding-left: 36pt; margin-left: 0px; list-style-type: none;" >        <li><font face="Arial" size="3" >&nbsp;</font><br>        <font face="Arial" size="3" >@ Philippe: Your right. Converting the 'attr' to an optional did do the job of creating a serial queue successfully. Thanks for that. I will create a PR for this.</font><br>        <font face="Arial" size="3" >&nbsp;</font><br>        <font face="Arial" size="3" >But this makes me think as to why until now, this was not caught by the compiler itself?</font><br>        <font face="Arial" size="3" >&nbsp;</font><br>        <font face="Arial" size="3" >Regards</font><br>        <font face="Arial" size="3" >Mamatha</font><br>        <font face="Arial" size="3" >&nbsp;</font>
        <ul style="padding-left: 3pt; margin-left: 0px; list-style-type: none;" >                <li><font face="Arial" size="3" >----- Original message -----<br>                From: </font><a href="mailto:phausler@apple.com" target="_blank" ><u><font color="#0000FF" face="Arial" size="3" >phausler@apple.com</font></u></a><br>                <font face="Arial" size="3" >To: Mamatha Busi/India/IBM@IBMIN<br>                Cc: swift-corelibs-dev &lt;</font><a href="mailto:swift-corelibs-dev@swift.org" target="_blank" ><u><font color="#0000FF" face="Arial" size="3" >swift-corelibs-dev@swift.org</font></u></a><font face="Arial" size="3" >&gt;<br>                Subject: Re: [swift-corelibs-dev] Setting property "maxConcurrentOperationCount = 1" of NSOperation fails to execute operations using OpenSource Foundation.<br>                Date: Thu, May 5, 2016 10:54 PM</font><br>                <br>                <font face="Arial" size="3" >Hmm that seems unfortunate. I wonder if the serial creation is due to an unwrapped optional? var attr: dispatch_queue_attr_t? instead might do the trick… or alternatively we could just let the underlying queue be concurrent all the time and enforce the max ops via making the semaphore always instantiated (in the case of max ops being 1) and initializing it to 1 to gate the operations.</font><br>                <font face="Arial" size="3" >&nbsp; </font>
                <ul style="padding-left: 36pt; margin-left: 0px; list-style-type: none;" >                        <li><font face="Arial" size="3" >On May 5, 2016, at 1:15 AM, Mamatha Busi via swift-corelibs-dev &lt;</font><a href="mailto:swift-corelibs-dev@swift.org" target="_blank" ><u><font color="#0000FF" face="Arial" size="3" >swift-corelibs-dev@swift.org</font></u></a><font face="Arial" size="3" >&gt;&nbsp;wrote:</font><br>                        <font face="Arial" size="3" >&nbsp; </font><br>                        <font face="Arial" size="3" >Hello</font><br>                        <font face="Arial" size="3" >&nbsp;</font>
                        <p><b><font face="Arial" size="3" >Code snippet:</font></b></p>
                        <p><font face="Arial" size="3" >———————————————————————</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp;let operation1 : NSBlockOperation = NSBlockOperation (block: {</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sleep(1)</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print("Opertion1")</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; })</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; let operation2 : NSBlockOperation = NSBlockOperation (block: {</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sleep(1)</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print("Opertion2”)</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; })</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; </font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; var operations = [NSOperation]()</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; operations.append(operation1)</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; operations.append(operation2)</font></p>
                        <p><font face="Arial" size="3" >&nbsp;</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; let queue = NSOperationQueue()</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; queue.maxConcurrentOperationCount = 1</font></p>
                        <p><font face="Arial" size="3" >&nbsp; &nbsp; &nbsp; &nbsp; queue.addOperations(operations, waitUntilFinished: true)</font></p>
                        <p><font face="Arial" size="3" >&nbsp;</font></p>
                        <p><font face="Arial" size="3" >———————————————————————— </font></p>
                        <p><font face="Arial" size="3" >&nbsp;</font></p>
                        <p><font face="Arial" size="3" >The above code snippet of adding operations to an operation queue and executing with the property ‘maxConcurrentOperationCount = 1’ fails while executing the above with the OpenSource Foundation and libDispatch of MAC inside Xcode. </font></p>
                        <p><font face="Arial" size="3" >The error I am seeing is: </font></p>
                        <p><b><font face="Arial" size="3" >fatal error: unexpectedly found nil while unwrapping an Optional value</font></b></p>
                        <p><b><font face="Arial" size="3" >Stack trace points to: </font></b><font face="Arial" size="3" >attr = DISPATCH_QUEUE_SERIAL </font></p>
                        <p><font face="Arial" size="3" >which implies that the libDispatch macro is coming as nil during the creation of the serial queue using libDispatch in the file NSOperationQueue</font></p>
                        <p><font face="Arial" size="3" >The same test-case passes on OSx. </font></p>
                        <p><font face="Arial" size="3" >When I do not restrict the serial operation i.e. I remove ‘ &nbsp;queue.maxConcurrentOperationCount = 1’ , test case executes successfully. </font></p>
                        <p><font face="Arial" size="3" >Setting it to a different value other than 1 also causes no problems. </font></p>
                        <p><font face="Arial" size="3" >Am I doing something wrong with the API. If I set the property ‘ queue.maxConcurrentOperationCount = 1’ after adding operations to the queue, then the problem does not occur. But then this restricts me to control the operation execution to be serial. So, I expect the above snippet to work on OpenSource as well. Any thoughts on this?</font></p>
                        <p><font face="Arial" size="3" >&nbsp;</font><br>                        <font face="Arial" size="3" >Thank you.</font><br>                        <font face="Arial" size="3" >&nbsp;</font><br>                        <font face="Arial" size="3" >Regards</font><br>                        <font face="Arial" size="3" >Mamatha</font><br>                        <font face="Arial" size="3" >&nbsp;</font><br>                        <br>                        <font face="Arial" size="3" >_______________________________________________<br>                        swift-corelibs-dev mailing list</font><br>                        <a href="mailto:swift-corelibs-dev@swift.org" target="_blank" ><u><font color="#0000FF" face="Arial" size="3" >swift-corelibs-dev@swift.org</font></u></a><br>                        <a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev" target="_blank" ><u><font color="#0000FF" face="Arial" size="3" >https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</font></u></a></p>                        </li>                </ul>                </li>        </ul>        <font face="Arial" size="3" >&nbsp;</font><br>        <tt><font face="" size="3" >_______________________________________________<br>        swift-corelibs-dev mailing list<br>        swift-corelibs-dev@swift.org</font></tt><br>        <tt><font face="" size="3" ><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev" target="_blank" >https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</a></font></tt><br>        &nbsp;</li></ul></blockquote>
<div dir="ltr" >&nbsp;</div></div><BR>