Re: Swift and Threads

2016-09-13 Thread Gerriet M. Denkmann
> On 13 Sep 2016, at 15:20, Quincey Morris > wrote: > >> On Sep 13, 2016, at 00:57 , Gerriet M. Denkmann wrote: >> >> I was struggling to find a solution which is thread safe. > > Your problem didn’t really need thread safety,

Re: Swift and Threads

2016-09-13 Thread Gerriet M. Denkmann
> On 13 Sep 2016, at 14:14, Stephen J. Butler wrote: > > This site suggests a version using withUnsafeMutableBufferPointer: > > http://blog.human-friendly.com/swift-arrays-are-not-threadsafe > > let nbrOfThreads = 8 > let step = 2 > let itemsPerThread = number * step

Re: Swift and Threads

2016-09-13 Thread Quincey Morris
On Sep 12, 2016, at 23:52 , Gerriet M. Denkmann wrote: > > I tried a variation of my function. This does not crash (not even in Debug > builds), but takes twice the memory and is about four times slower: I no longer understand what we’re doing here. Based on the code

Re: Swift and Threads

2016-09-13 Thread Alastair Houghton
On 13 Sep 2016, at 05:29, Jens Alfke wrote: > > The Bool type is one byte in size. > > C++ has a specialization for std::vector that makes it a true bit > array, but I’m not sure if Swift’s generic system is powerful enough to be > able to entirely switch out the

Re: Swift and Threads

2016-09-13 Thread Stephen J. Butler
This site suggests a version using withUnsafeMutableBufferPointer: http://blog.human-friendly.com/swift-arrays-are-not-threadsafe let nbrOfThreads = 8 let step = 2 let itemsPerThread = number * step let bitLimit = nbrOfThreads * itemsPerThread var bitfield = [Bool](count: bitLimit,

Re: Swift and Threads

2016-09-13 Thread Gerriet M. Denkmann
> On 12 Sep 2016, at 22:49, Jens Alfke wrote: > > >> On Sep 12, 2016, at 6:42 AM, Gerriet M. Denkmann >> wrote: >> >> So: is the code ok and the compiler broken in Debug mode? >> Or is the code fundamentally wrong and that it works in Release is