discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

none


From: allynm
Subject: none
Date: Sun, 14 Jun 2015 16:12:48 -0700 (MST)

Hello everyone,

I'm working on a fresh install of libobjc2, gnustep, libdispatch.  I think
I've gotten ARC and dispatch_queue functionality going, but I'm getting
intermittent failures using this code:


> ///Bockarc.m
> #import 
> <
> Foundation/Foundation.h
> >
> #import 
> <
> dispatch/dispatch.h
> >
> int main()
> {
> 
> @autoreleasepool{
> __block int res;
> 
> //create a block that does simple multiplication of two ints
> 
> int (^B1)(int, int)=^(int num1, int num2){
> return num1*num2;
> };
> 
> 
> //test the block!
> 
> int result = B1(4,5);
> NSLog(@"The result of the call to the block is %d \n", result);
> 
> 
> //create a dispatch queue that will run the block
> 
> dispatch_queue_t myQ;
> myQ = dispatch_queue_create("forg.u.q.example", NULL);
> dispatch_async(myQ,^{res = B1(4,5);
>     NSLog(@" The answer to the little multiplication routine is %d \n"
> ,res);}); 
>   }
> return 0;
> }

The second NSLog call that should print out the results of the B1 invocation
in the dispatch queue fails intermittenly.  Can't figure it out.

I'm building the program with this code:


> clang -I. `gnustep-config --objc-flags` -fobjc-arc -fblocks  -x
> objective-c blockarc.m `gnustep-config --gui-libs` -ldispatch -o blockarc

I'm out of ideas.

Thanks,
Mark Allyn



--
View this message in context: http://gnustep.8.n7.nabble.com/none-tp39402.html
Sent from the GNUstep - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]