|
|
Choosing A Webhost: |
Threads Best Practices: msg#00187apache.apr.devel
Hi there, I'm really starting to get into APR. I was able to port to APR mutexes without a hitch. However, I'm a bit confused on threads, and I'd appreciate any direction you can offer: 1) What should I do with "apr_threadattr_t"? Need I create one, or can I pass NULL for that field into "apr_thread_create"? If I need to create one, do I need to do anything with it, or can I use it with its default state? 2) What's the proper way to declare an "apr_start_thread_t" function? Is this what I'm supposed to do? # void* ThreadProc( apr_thread_t* thread, void* data ) { } # void foo( ) # { # ... # apr_thread_create( # &thread, # attr, # (apr_thread_start_t)ThreadProc, # (void*)data, # pool # ); # } 3) What's the portable equivalent to Win32's "GetCurrentThreadId( )"? I'd like to associate some data with the thread, and then query it down the road. Currently I use "GetCurrentThreadId( )" in conjunction with my own global map. What I'd like to do us "apr_thread_data_get( )" to just query the current thread's data, but it looks like I need to know the thread's handle. Is there any way to look up the handle for the current thread, or query the data of the current thread without knowing its handle? 4) What's the proper way to clean up a thread? I'm new to the whole "pool" paradigm; do I simply destroy the pool I used to create the thread and its attribute? I assume I need to "apr_thread_join( )" on that thread first, correct? 5) What's the portable equivalent to Win32's "Sleep( )" function? I see there is "apr_thread_yield( )", but that's not quite the same. I'd like to explicitly sleep the thread for some period; can APR do this? Thanks for all your help, and the excellent library! -david PS: Is there any more-accessible form of the dev@xxxxxxxxxxxxxx archives than what's posted up on http://apr.apache.org/mail/dev/? I'm finding it difficult to search that effectively. Alternatively, can you recommend any better tools for searching the archives than "grep" and "vi"? Like... Google? :)
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: Static Linked on Linux and Win32, David Barrett |
|---|---|
| Next by Date: | RE: Threads Best Practices, Dror Shilo |
| Previous by Thread: | Re: 1.1.0 RCx configure error, Joe Orton |
| Next by Thread: | RE: Threads Best Practices, Dror Shilo |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |