Re: Re: [boost] Re: A new boost::thread implementation?

2003-02-12 Thread William E. Kempf
Sorry for late reply... had a hard disk problem that prevented accessing e-mail. Peter Dimov said: William E. Kempf wrote: How about this compromise: template typename R class async_call { public: template typename F explicit async_call(const F f) : m_func(f) {

Re: Re: [boost] Re: A new boost::thread implementation?

2003-02-12 Thread William E. Kempf
Peter Dimov said: William E. Kempf wrote: It's not just the efficiencies that concern me with dynamic allocation. It's the additional points of failure that occur in this case as well. For instance, check out the article on embedded coding in the most recent CUJ (sorry, don't have the

Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread Peter Dimov
David Abrahams wrote: Peter Dimov [EMAIL PROTECTED] writes: I am not saying that this is never useful, but syntax should target the typical scenario, not corner cases. Agreed. I suppose that you'll say it doesn't target the typical scenario because of its confusability. I wouldn't argue.

Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread David Abrahams
Peter Dimov [EMAIL PROTECTED] writes: David Abrahams wrote: Peter Dimov [EMAIL PROTECTED] writes: I am not saying that this is never useful, but syntax should target the typical scenario, not corner cases. Agreed. I suppose that you'll say it doesn't target the typical scenario because

Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread Peter Dimov
David Abrahams wrote: Peter Dimov [EMAIL PROTECTED] writes: We have three concepts: Runnable, Executor (executes Runnables), and HasResult (for lack of a better name.) The AsyncCall concept I had in mind is both Runnable and HasResult, so it can't use operator() for both. x.result() or

Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread David Abrahams
William E. Kempf [EMAIL PROTECTED] writes: Actually, there's another minor issue as well. The user can call operator() and then let the async_call go out of scope with out ever calling result(). Mayhem would ensue. The two options for dealing with this are to either block in the destructor

Re: Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread William E. Kempf
From: David Abrahams [EMAIL PROTECTED] Date: 2003/02/10 Mon AM 11:15:31 EST To: Boost mailing list [EMAIL PROTECTED] Subject: Re: [boost] Re: A new boost::thread implementation? William E. Kempf [EMAIL PROTECTED] writes: Actually, there's another minor issue as well. The user can

Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread David Abrahams
William E. Kempf [EMAIL PROTECTED] writes: From: David Abrahams [EMAIL PROTECTED] Date: 2003/02/10 Mon AM 11:15:31 EST To: Boost mailing list [EMAIL PROTECTED] Subject: Re: [boost] Re: A new boost::thread implementation? William E. Kempf [EMAIL PROTECTED] writes: Actually, there's

Re: Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread Peter Dimov
William E. Kempf wrote: From: Peter Dimov [EMAIL PROTECTED] // step 2: execute an async_call call(); This example, and the implementation above, are just complex synchronous calls. I assume you really meant for either the constructor or this call to also take an Executor concept?

Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread David Abrahams
Peter Dimov [EMAIL PROTECTED] writes: Unspecified, but I don't think we can avoid that with the low-level interface. High level wrappers that package creation and execution would be immune to this problem. Is there really a need for a low-level async_call interface? After all, the existing

Re: Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread William E. Kempf
From: Peter Dimov [EMAIL PROTECTED] Date: 2003/02/10 Mon PM 12:54:28 EST To: Boost mailing list [EMAIL PROTECTED] Subject: Re: Re: [boost] Re: A new boost::thread implementation? William E. Kempf wrote: From: Peter Dimov [EMAIL PROTECTED] // step 2: execute an async_call

Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread Peter Dimov
David Abrahams wrote: Peter Dimov [EMAIL PROTECTED] writes: Unspecified, but I don't think we can avoid that with the low-level interface. High level wrappers that package creation and execution would be immune to this problem. Is there really a need for a low-level async_call interface?

Re: Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread William E. Kempf
From: David Abrahams [EMAIL PROTECTED] William E. Kempf [EMAIL PROTECTED] writes: I lean towards simple undefined behavior. How do you feel about it? I have a feeling that I'm not being asked here, and maybe even that it's wasted breath because you've grown tired of my emphasis on a

Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread Peter Dimov
David Abrahams wrote: Peter Dimov [EMAIL PROTECTED] writes: David Abrahams wrote: Peter Dimov [EMAIL PROTECTED] writes: Unspecified, but I don't think we can avoid that with the low-level interface. High level wrappers that package creation and execution would be immune to this problem.

Re: Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread Peter Dimov
William E. Kempf wrote: How about this compromise: template typename R class async_call { public: template typename F explicit async_call(const F f) : m_func(f) { } void operator()() { mutex::scoped_lock lock(m_mutex); if (m_result)

Re: Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread Peter Dimov
William E. Kempf wrote: It's not just the efficiencies that concern me with dynamic allocation. It's the additional points of failure that occur in this case as well. For instance, check out the article on embedded coding in the most recent CUJ (sorry, don't have the exact title handy).

Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread David Abrahams
William E. Kempf [EMAIL PROTECTED] writes: From: David Abrahams [EMAIL PROTECTED] Peter Dimov [EMAIL PROTECTED] writes: It's a tool that allows high-level interfaces to be built. Whether people will want/need to build their own high-level interfaces is another story. I think it's a

Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread David Abrahams
William E. Kempf [EMAIL PROTECTED] writes: No, I was asking anyone interested in responding, and you're certainly not wasting your breath. I think I reached a compromise on these issues/questions, and would appreciate your response (it's in another post). Done. Allocation can be pretty

Re: [boost] Re: A new boost::thread implementation?

2003-02-10 Thread David Abrahams
Peter Dimov [EMAIL PROTECTED] writes: I can. On the other hand, I can implement the thread primitives and optional, too. The point is that if, while building a high-level interface implementation, we discover an useful low-level primitive that offers greater expressive power (if less safety),

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread Peter Dimov
David Abrahams wrote: [...] Well, I don't really feel like arguing about this much longer. I'd love to contribute to this discussion but there's no firm ground to stand on. What _are_ the concepts being discussed? I think I see AsyncCallR AsyncCall(functionR () f); void operator()();

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread David Abrahams
Peter Dimov [EMAIL PROTECTED] writes: David Abrahams wrote: [...] Well, I don't really feel like arguing about this much longer. I'd love to contribute to this discussion but there's no firm ground to stand on. What _are_ the concepts being discussed? I think I see AsyncCallR

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread Peter Dimov
David Abrahams wrote: Peter Dimov [EMAIL PROTECTED] writes: David Abrahams wrote: [...] Well, I don't really feel like arguing about this much longer. I'd love to contribute to this discussion but there's no firm ground to stand on. What _are_ the concepts being discussed? I think I

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread David Abrahams
Peter Dimov [EMAIL PROTECTED] writes: David Abrahams wrote: That's the general idea. Of course we can haggle over the syntactic details, but the main question is whether you can get a return value from invoking a thread function or whether you have to declare some global state and ask the

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread Peter Dimov
David Abrahams wrote: Peter Dimov [EMAIL PROTECTED] writes: With the above AsyncCall: async_callint f( bind(g, 1, 2) ); // can offer syntactic sugar here thread t(f); // or thread(f); for extra cuteness int r = f.result(); The alternative seems to be async_callint f( bind(g, 1, 2) );

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread David Abrahams
Peter Dimov [EMAIL PROTECTED] writes: David Abrahams wrote: Peter Dimov [EMAIL PROTECTED] writes: With the above AsyncCall: async_callint f( bind(g, 1, 2) ); // can offer syntactic sugar here thread t(f); // or thread(f); for extra cuteness int r = f.result(); The alternative seems to

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread Peter Dimov
David Abrahams wrote: Peter Dimov [EMAIL PROTECTED] writes: Using an undefined-yet Executor concept for the first argument. This is not much different from async_callint f( bind(g, 1, 2) ); // execute f using whatever Executor is appropriate int r = f.result(); except that the async_call

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread William E. Kempf
David Abrahams said: William E. Kempf [EMAIL PROTECTED] writes: David Abrahams said: ...and if it can't be default-constructed? That's what boost::optional is for ;). Yeeeh. Once the async_call returns, you have a value, and should be able to count on it. You shouldn't get back an

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread William E. Kempf
David Abrahams said: Peter Dimov [EMAIL PROTECTED] writes: David Abrahams wrote: Peter Dimov [EMAIL PROTECTED] writes: With the above AsyncCall: async_callint f( bind(g, 1, 2) ); // can offer syntactic sugar here thread t(f); // or thread(f); for extra cuteness int r = f.result(); The

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread David Abrahams
Alexander Terekhov [EMAIL PROTECTED] writes: But I still insist ( ;-) ) on a rather simple interface for creating a thread object (that shall kinda-encapsulate that async_callT-thing representing the thread routine with its optional parameter(s) and return value... and which can be

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread David Abrahams
Peter Dimov [EMAIL PROTECTED] writes: except that the async_call doesn't need to know about Executors. ...and that you don't need a special syntax to get the result out that isn't compatible with functional programming. If you want to pass a function object off from the above, you need

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread David Abrahams
William E. Kempf [EMAIL PROTECTED] writes: except that the async_call doesn't need to know about Executors. ...and that you don't need a special syntax to get the result out that isn't compatible with functional programming. If you want to pass a function object off from the above, you need

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread William E. Kempf
David Abrahams said: Peter Dimov [EMAIL PROTECTED] writes: The line in the middle won't work, actually, but that's another story. boost::thread() creates a handle to the current thread. ;-) Score another one for defining concepts before using them. Oh, I'm not up on the new interface. How

Re: [boost] Re: A new boost::thread implementation?

2003-02-08 Thread David Abrahams
William E. Kempf [EMAIL PROTECTED] writes: David Abrahams said: William E. Kempf [EMAIL PROTECTED] writes: David Abrahams said: ...and if it can't be default-constructed? That's what boost::optional is for ;). Yeeeh. Once the async_call returns, you have a value, and should be able to

RE: [boost] Re: A new boost::thread implementation?

2003-02-07 Thread William E. Kempf
Darryl Green said: -Original Message- From: William E. Kempf [mailto:[EMAIL PROTECTED]] Dave Abrahams said: Hm? How is the result not a result in my case? I didn't say it wasn't a result, I said that it wasn't only a result. In your case it's also the call. Regardless of

Re: [boost] Re: A new boost::thread implementation?

2003-02-07 Thread William E. Kempf
David Abrahams said: ...and if it can't be default-constructed? That's what boost::optional is for ;). Yeeeh. Once the async_call returns, you have a value, and should be able to count on it. You shouldn't get back an object whose invariant allows there to be no value. I'm not sure I can

Re: [boost] Re: A new boost::thread implementation?

2003-02-07 Thread David Abrahams
William E. Kempf [EMAIL PROTECTED] writes: David Abrahams said: ...and if it can't be default-constructed? That's what boost::optional is for ;). Yeeeh. Once the async_call returns, you have a value, and should be able to count on it. You shouldn't get back an object whose invariant

Re: [boost] Re: A new boost::thread implementation?

2003-02-06 Thread William E. Kempf
double d; threaddouble t = spawn(foo)(a,b,c); // do something else d = thread.return_value(); A solution like this has been proposed before, but I don't like it. This creates multiple thread types, instead of a single thread type. I think this will only make the

Re: [boost] Re: A new boost::thread implementation?

2003-02-06 Thread Dave Abrahams
From: Wolfgang Bangerth [EMAIL PROTECTED] double d; threaddouble t = spawn(foo)(a,b,c); // do something else d = thread.return_value(); A solution like this has been proposed before, but I don't like it. This creates multiple thread types, instead of a single

Re: [boost] Re: A new boost::thread implementation?

2003-02-06 Thread William E. Kempf
From: Wolfgang Bangerth [EMAIL PROTECTED] This does the same, indeed. Starting a thread this way is just a little more complex (and -- in my view -- less obvious to read) than writing thread t = spawn(foo)(a,b,c); But that's just personal opinion, and I'm arguably biased :-) I'm sure

Re: [boost] Re: A new boost::thread implementation?

2003-02-06 Thread Dave Abrahams
From: William E. Kempf [EMAIL PROTECTED] From: Wolfgang Bangerth [EMAIL PROTECTED] This does the same, indeed. Starting a thread this way is just a little more complex (and -- in my view -- less obvious to read) than writing thread t = spawn(foo)(a,b,c); But that's just personal

Re: [boost] Re: A new boost::thread implementation?

2003-02-06 Thread Wolfgang Bangerth
async_resultdouble res; thread t(bind(res.call(), a, b, c)); // do something else d = res.value(); // Explicitly waits for the thread to return a value? This does the same, indeed. Starting a thread this way is just a little more complex (and -- in my view -- less obvious to

Re: [boost] Re: A new boost::thread implementation?

2003-02-06 Thread William E. Kempf
Dave Abrahams said: Hmm... that would be an interesting alternative implementation. I'm not sure it's as obvious as the syntax I suggested Sorry, IMO there's nothing obvious about your syntax. It looks cumbersome and low-level to me. Let me suggest some other syntaxes for async_result,

Re: [boost] Re: A new boost::thread implementation?

2003-02-06 Thread Dave Abrahams
On Thursday, February 06, 2003 12:33 PM [GMT+1=CET], William E. Kempf [EMAIL PROTECTED] wrote: Dave Abrahams said: Hmm... that would be an interesting alternative implementation. I'm not sure it's as obvious as the syntax I suggested Sorry, IMO there's nothing obvious about your

Re: [boost] Re: A new boost::thread implementation?

2003-02-06 Thread William E. Kempf
Dave Abrahams said: On Thursday, February 06, 2003 12:33 PM [GMT+1=CET], William E. Kempf [EMAIL PROTECTED] wrote: Dave Abrahams said: Hmm... that would be an interesting alternative implementation. I'm not sure it's as obvious as the syntax I suggested Sorry, IMO there's nothing

Re: [boost] Re: A new boost::thread implementation?

2003-02-05 Thread William E. Kempf
Hi Ove, f. It shall be possible to send extra information, as an optional extra argument to the boost::thread ctor, to the created thread. boost::thread::self shall offer a method for retrieving this extra information. It is not required that this information be passed in a