• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Working with C-functions in separate NSThreads: via Stack or Heap?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Working with C-functions in separate NSThreads: via Stack or Heap?


  • Subject: Working with C-functions in separate NSThreads: via Stack or Heap?
  • From: "Frederick C. Lee" <email@hidden>
  • Date: Thu, 4 Nov 2010 15:04:05 -0700

Environment: iOS SDK 4.2+
Xcode 3.2.5

Desired design:
   1) Multiple NSThreads (via NSOperation?) running NSObjects in parallel: processing the same C-functions (with different data) in real time till conclusion (or cancelled).
   2) These C-functions are located in a common *.c file (or two); could (& probably shall) be in *.m files instead.
   3) C-based data results are displayed & updated (e.g.,a counter) with IB per each iteration (with option to wait till conclusion, then displayed).

Greetings:
    I need to interface between an instantiated NSObject with ANSI-C (shall be C99+ in Xcode) functions (within member *.c files).
I'll probably change these *.c files to *.m files.

On the surface, all is okay.

I can pass a typedef  struct thusly (malloc isn't used, straight call & receive):

typedef struct {
        char *satName;
	char *satCategory;
        char *website;
...
...
} sat_t;
--------------
sat_t workingSat;
...
initSatWorkArea(&workingSat);   <--- a NSObject's method (in head) is accessing a C-function (on stack)?

However, I'm concerned about memory usage & stability.

Am I correct that these C functions are within the Stack vs Heap...
...and thus these C-functions (in the stack) are accessed from the heap (from within an instantiated NSObject).  Correct?

1) Does that mean the data generated from these C-functions will be popped/released, once exit from the calling Objective-C method?
2) I assume it doesn't matter where these C-functions are located, from within an instantiated NSObject or from a member *.c file (via #import); behavior is the same.
3) Do I need to hassle with malloc() for C-structures that are passed between the calling instantiated NSObject?
    Note: I need to keep these C-based calculations continuous (with option to display the changing results in the foreground (IB GUI)); within their respective threads (could be only 1 thread).
4) Would using blocks be the ideal (Apple-recommended) way of doing this?

Regards,

Ric.




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: NSColorWell in a NSTableView
  • Next by Date: Re: Setting (not saving) NSPersistentDocument Metadata changes file Modification Date
  • Previous by thread: Re: NSColorWell in a NSTableView
  • Next by thread: Re: Working with C-functions in separate NSThreads: via Stack or Heap?
  • Index(es):
    • Date
    • Thread