• 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
Re: how many threads/tasks are running in my application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how many threads/tasks are running in my application


  • Subject: Re: how many threads/tasks are running in my application
  • From: Shawn Erickson <email@hidden>
  • Date: Sat, 10 Jan 2004 12:43:43 -0800

On Jan 10, 2004, at 9:06 AM, Shawn Erickson wrote:

I may finish it some day and make it available to folks... (sleep always gets in the way however)

A pre-release version of the above mentioned thread pool framework can be downloaded from the following link. It should be functional and has passed the tests I have tried so far but it is still configured in a debug mode so it had symbols and will spit stuff to the console as it is used. Note the framework is configured to run on Mac OS X 10.3 and later (it is using the new @try / @catch / etc. support). I may release the source for it in the future...

http://homepage.mac.com/shawnce/ftsw/FTSWThreadPool_0_1.zip

The following simple foundation tool shows the thread pool being used...

#import <Foundation/Foundation.h>
#include <unistd.h>
#import "FTSWThreadPool.h"

@interface FTSWThreadPoolTester : NSObject {
int _tag;
}
- (id) initWithTag:(int)tag;
- (void) test;
@end

@implementation FTSWThreadPoolTester
- (id) initWithTag:(int)tag {
_tag = tag;
return self;
}

- (void) test {
NSLog(@"%d - tester started", _tag);

[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:5.0]];

NSLog(@"%d - tester finished", _tag);
}
@end

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

FTSWThreadPool* threadPool = [[FTSWThreadPool alloc] initWithMaxPoolThreads:2
maxThreads:4];

int i;
for (i = 1; i <= 15; i++) {
NSLog(@"%d - started", i);

[threadPool messageSelector:@selector(test)
toTarget:[[[FTSWThreadPoolTester alloc] initWithTag:i] autorelease]
withObject:nil];

[pool release];
pool = [[NSAutoreleasePool alloc] init];

sleep(1);
}

sleep(30);

for (; i <= 30; i++) {
NSLog(@"%d - started", i);

[threadPool messageSelector:@selector(test)
toTarget:[[[FTSWThreadPoolTester alloc] initWithTag:i] autorelease]
withObject:nil];

[pool release];
pool = [[NSAutoreleasePool alloc] init];

sleep(1);
}

[threadPool release];

sleep(30);

[pool release];

sleep(360);

return 0;
}


-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >how many threads/tasks are running in my application (From: "Ramakrishna Kondapalli" <email@hidden>)
 >Re: how many threads/tasks are running in my application (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Re: Large number support (BIG INT)
  • Next by Date: Python from Objective-C?
  • Previous by thread: Re: how many threads/tasks are running in my application
  • Next by thread: Inter-Object Reference
  • Index(es):
    • Date
    • Thread