[swift-users] Swift and Threads

2016-09-12 Thread Gerriet M. Denkmann via swift-users
This function works flawlessly in Release build: func markAndTell( talk: Bool, number: Int) { let nbrOfThreads = 8 let step = 2 let itemsPerThread = number * step let bitLimit = nbrOfThreads * itemsPerThread var bitfield = [Bool](count: bitLimit,

Re: [swift-users] Swift and Threads

2016-09-13 Thread Gerriet M. Denkmann via swift-users
> On 13 Sep 2016, at 14:49, Quinn The Eskimo! via swift-users > <swift-users@swift.org> wrote: > > > On 13 Sep 2016, at 05:03, Gerriet M. Denkmann via swift-users > <swift-users@swift.org> wrote: > >> Or is the code fundamentally wrong …? > > Th

Re: [swift-users] Swift 3 likes to tease me

2016-09-23 Thread Gerriet M. Denkmann via swift-users
> On 23 Sep 2016, at 12:09, Marco S Hyman <m...@snafu.org> wrote: > > On Sep 22, 2016, at 9:51 PM, Gerriet M. Denkmann via swift-users > <swift-users@swift.org> wrote: >> >> This line (Swift 3): >> if a.responds(to: Selector(“viewControllers&q

[swift-users] Swift 3 likes to tease me

2016-09-22 Thread Gerriet M. Denkmann via swift-users
This line (Swift 3): if a.responds(to: Selector(“viewControllers") ) creates this warning: Use '#selector' instead of explicitly constructing a 'Selector' Ok. Following this advice I change it to: if a.responds(to: #selector(“viewControllers")) and now get an error instead:

[swift-users] How to malloc in Swift 3

2016-09-23 Thread Gerriet M. Denkmann via swift-users
This used to work in Swift 2.2: var bitfield: UnsafeMutablePointer? bitfield = UnsafeMutablePointer( malloc( 888 ) ) How is this written in Swift 3.0? Gerriet. ___ swift-users mailing list swift-users@swift.org

Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Gerriet M. Denkmann via swift-users
ted, but not initialized.” What about calloc then? Or use allocate and do a memset afterwards? Thanks a lot for your help! Kind regards, Gerriet. >> 23. sep. 2016 kl. 10.47 skrev Gerriet M. Denkmann via swift-users >> <swift-users@swift.org>: >> >> This used to work i

Re: [swift-users] How to malloc in Swift 3

2016-09-23 Thread Gerriet M. Denkmann via swift-users
> On 23 Sep 2016, at 15:47, Gerriet M. Denkmann via swift-users > <swift-users@swift.org> wrote: > > This used to work in Swift 2.2: > > var bitfield: UnsafeMutablePointer? > bitfield = UnsafeMutablePointer( malloc( 888 ) ) > > How is this written in Swif

Re: [swift-users] CharacterSet vs Set

2016-10-03 Thread Gerriet M. Denkmann via swift-users
> On 3 Oct 2016, at 19:17, Jean-Denis Muys via swift-users > wrote: > > You are right: I don’t know much about asian languages. > > How would you go about counting consonants, vowels (and tone-marks?) in the > most general way? Iterate over unicodeScalars (in the most

Re: [swift-users] CharacterSet vs Set

2016-10-03 Thread Gerriet M. Denkmann via swift-users
> On 3 Oct 2016, at 16:28, Jean-Denis Muys via swift-users > wrote: > > ASCII? Probably not. Latin? perhaps, though not obvious. For example French > accented letters would probably have to be handled somehow. Greek or > Cyrillic? Perhaps. Other scripts? Unlikely, but

Re: [swift-users] How to malloc in Swift 3

2016-09-24 Thread Gerriet M. Denkmann via swift-users
> On 23 Sep 2016, at 19:41, Quinn The Eskimo! via swift-users > <swift-users@swift.org> wrote: > > > On 23 Sep 2016, at 11:29, Gerriet M. Denkmann via swift-users > <swift-users@swift.org> wrote: > >> What about calloc then? Or use allocate and do a m

[swift-users] QualityOfService for concurrentPerform in Swift 3

2016-09-25 Thread Gerriet M. Denkmann via swift-users
In ObjC: dispatch_queue_t queue = dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0 ); dispatch_apply( nbrThreads, queue, ^void(size_t idx) … In Swift 3: DispatchQueue.concurrentPerform( iterations: nbrThreads) … How can one specify the DISPATCH_QUEUE_PRIORITY or

Re: [swift-users] QualityOfService for concurrentPerform in Swift 3

2016-09-25 Thread Gerriet M. Denkmann via swift-users
> On 25 Sep 2016, at 23:08, Saagar Jha <saa...@saagarjha.com> wrote: > > You might be looking for the DispatchQoS.QoSClass enum. > > Saagar Jha Probably. But how to make concurrentPerform use any of these enums? Gerriet. > >> On Sep 25, 2016, at 05:19, Gerri

[swift-users] Looping with UInt64

2016-10-12 Thread Gerriet M. Denkmann via swift-users
With: let nbrBytes = 400_000_000 let localArray = UnsafeMutablePointer.allocate(capacity: nbrBytes) // touch every page before summing: for i in 0 ..< nbrBytes / 4096 { localArray[ 4096 * i ] = 1 } This rather innocent loop: var count: UInt64 = 0 for index in 0 ..< loopLimit { count +=

[swift-users] Why are Swift Loops slow?

2016-10-12 Thread Gerriet M. Denkmann via swift-users
uint64_t nbrBytes = 4e8; uint64_t count = 0; for( uint64_t byteIndex = 0; byteIndex < nbrBytes; byteIndex++ ) { count += byteIndex; if ( ( byteIndex & 0x ) == 0 ) { count += 1.3; } (AAA) }; Takes 260 msec. Btw.: Without the (AAA) line the whole loop is done in 10 μsec.

[swift-users] Counting in Threads

2016-10-12 Thread Gerriet M. Denkmann via swift-users
How to translate this to Swift: __block atomic_uint_fast64_t counter = ATOMIC_VAR_INIT(0); dispatch_apply( nbrInterations, queue, ^void(size_t idx) { uint64_t tCount = 0; ... do some counting ... atomic_fetch_add_explicit( , tCount,

Re: [swift-users] Why are Swift Loops slow?

2016-10-12 Thread Gerriet M. Denkmann via swift-users
> On 12 Oct 2016, at 23:05, Joe Groff via swift-users <swift-users@swift.org> > wrote: > >> >> On Oct 12, 2016, at 2:25 AM, Gerriet M. Denkmann via swift-users >> <swift-users@swift.org> wrote: >> >> uint64_t nbrBytes = 4e8; >> uint

Re: [swift-users] How to write better Swift

2017-07-10 Thread Gerriet M. Denkmann via swift-users
ected code below > var status: Int { > didSet { doSomething() } > } > > Geordie > > >> Am 10.07.2017 um 17:34 schrieb Gerriet M. Denkmann via swift-users >> <swift-users@swift.org>: >> >> This works (Xcode Version 8.3.2 (8E2002)): >> >>

[swift-users] How to write better Swift

2017-07-10 Thread Gerriet M. Denkmann via swift-users
This works (Xcode Version 8.3.2 (8E2002)): class SomeClass { private var privateStatus: Int var status: Int { get{ return privateStatus } set(new) { if new == privateStatus {return}