POSIX C++ Study Group
SC22 ballot document N4217 for IEEE P1003.1, Draft 3.
Meeting location: IBM Software Lab meeting room at 8200 Warden Avenue, Markham, Ontario, Canada.
Ulrich Drepper called the meeting to order at 9:41 hrs.
Minutes by Jens Maurer.
Introductions
Attendees (in alphabetical order of last name):
- Hans Boehm, HP hans.boehm@hp.com
- Eric Christopher, Apple echristo@gmail.com
- Lawrence Crowl, Google lawrence@crowl.org
- Don Cragun, Sun Microsystems don.cragun@sun.com
- Ulrich Drepper, Red Hat drepper@redhat.com
- Michael Wong, IBM michaelw@ca.ibm.com
- Lois Goldthwaite, United Kingdom lois@loisgoldthwaite.com
- Howard Hinnant, Apple hinnant@twcny.rr.com
- Robert Klarer, IBM klarer@ca.ibm.com (part time)
- Benjamin Kosnik, Red Hat bkoz@redhat.com
- Jens Maurer, on vacation Jens.Maurer@gmx.net
- Jason Merrill, Red Hat jason@redhat.com
- P.J. ("Bill") Plauger, Dinkumware pjp@dinkumware.com
- Tana Plauger, Dinkumware tana@dinkumware.com
- Tom Plum, Plum Hall tplum@plumhall.com (joined after lunch)
- Nick Stoughton, Usenix nick@usenix.org
- Detlef Vollmann, Siemens dv@vollmann.ch
- Sean Perry, IBM perry@ca.ibm.com
- Thomas Witt, Zephyr Associates witt@acm.org
Don, Nick, Ulrich are part of the base working group for POSIX.
Others are are affiliated with WG21.
Lunch break is from 12:00 to 13:30 hrs. Hotel restaurants, shopping
plaza at the intersection of highway 7 and Warden Avenue, and Chinese
mall (on Warden Avenue towards Richmond) are available.
Ulrich: This is an official IEEE meeting. The task of the Study
Group is to find out whether there is enough interest and create a PAR.
In particular, we have to define the scope (as detailed as feasible),
timeline, and officers of the Working Group.
Agenda
- Wrap up by 5pm, come together at 15:30 or 16:00 hrs to review the results.
- Introductions
- Purpose: PAR and Criteria for a future POSIX C++ WG
- define scope
- specify timeline
- determine officers
- Presentation of different approaches (Nick)
- collaboration
- organization
- POSIX recent development (Ulrich)
- C++ library recent development (Benjamin, maybe others)
- Specific topics
- threads
- other library functionality
Lawrence's e-mail from Friday is more concerned with presentation/implementation details, no effect on agenda.
The agenda is unanimously agreed upon.
Presentation of different approaches
Nick: Formation of the Austin Group as a joint working group of ISO,
the Open Group, and IEEE. Draft 3 is currently in simultaneous ballot
in all three entities.
For a POSIX/C++ binding, there are a number of approaches. Ada has a
"thick" binding, i.e. it rewrote the entire POSIX standard in terms of
Ada. Fortran did a "thin" binding, i.e. it just maps the syntax
function-by-function to the C binding. Do we want a thick or a thin
binding? Experience tells us that thin bindings are a lot easier to
maintain.
C++0x is already doing a lot of stuff that relates to POSIX, thus there
is overlap between POSIX and C++0x efforts, for example threads. Maybe
one approach is not to write a separate standard. Maybe make it part of
C++0x, but the timetable may be prohibitive. Or produce a Technical
Report. We should not have competing standards ("standard C++ threads"
and "POSIX threads") that are mutually incompatible.
Are we doing the right thing, trying to come up with a separate International Standard for a POSIX/C++ binding?
Lawrence: C++ is aiming for generality, POSIX is aiming towards control.
Ulrich: We are envisioning an add-on extension integrated into
the C++ facilities, similar to POSIX extending standard C functions.
Benjamin: We're going to see a lot more overlap between the C++
library and POSIX, e.g. system_error, threads, also C++03 locales. Some
kind of study is warranted to make sure the same terms mean the same
thing.
Bill: More of the POSIX interface is exposed in the C++
interface with C++0x. There have been serious efforts in the last
quarter century that C, C++, and POSIX play together, but have clear
division. Central question: Why do we want to have another binding
document? What do you have to say in a POSIX/C++ document that is not
better said in C or C++ or POSIX? Focus on the C++/POSIX interaction
specialities.
Ulrich: We are not artificially introducing C++ bindings if the C binding is perfectly fine.
Nick: Good point about existing practice. In the POSIX world, a
fundamental part is "Has this been implemented? How widespread is
existing practice?". This approach came from experience in the early
90ies. We should keep the invention part to an absolute minimum.
Tana: If it's invented, there should be an implementation.
Ulrich: We should define what "existing practice" means, for example "one implementation, tested for half a year".
Bill: Speaking out for backward compatibility, important for his customer community.
Hans Boehm: In some places, we have to invent, because there is no existing practice that works.
Ulrich: Yes, but that does not exclude that there is an implementation at standards ballot time, otherwise it's out.
Nick: Wants to have the bar fairly high on the "existing practice".
Ulrich: C++ library group should not cave in to pressure, do it
right instead of only having a minimal feature set in the next
standard.
Lawrence: The library is much more embedded in the ABIs than
most people seem to realize. ABI incompatibilities later will decrease
the adoption rate. Therefore, we must plan for later changes now.
Ulrich: With advanced C++ features, this might be less of an issue than feared.
Thomas Witt: The time pressure is real, people have the need to do threading.
Bill: Different to "export" or other features, people have been
doing threading for tens of years. The question is whether we can
convince people to switch to the "standard" way of doing threading.
Hans Boehm: We see people use 99.9% percent solutions that
don't work all of the time. We want to provide a 100% solution.
Example: Interaction of static object destruction and threads that live
until process end.
Ulrich: Need not to be covered in the C++ standard, can be covered in the POSIX/C++ binding.
Lawrence: Programmers need guidance on how to write good applications.
Ulrich: Disregarding systems programmers, the best advice to programmers is "don't use threads". OpenMP and other approaches provide a better service to programmers.
Lawrence: A lot of the current C++0x extensions are targeted to
library developers, providing mechanism for higher-level libraries.
POSIX recent development
Ulrich: Some functions are deprecated in POSIX, but N2298 recommends
them, e.g. strerror_r (it's an incomplete solution), replaced by
strerror_l; rand_r (came from POSIX.1c, was a mistake), being removed
from the standard (it only has a state of 31 bits); concept of
thread-local locales (based on glibc implementation to handle C++
iostreams locales): locales are objects, you can pass them to
functions, the default behavior is backward compatible.
Other new group of functionality: Have the current working
directory play a lesser role (due to all threads sharing the same
current working directory), so at-functions are added which take a
directory file descriptor. Relative paths are interpreted relative to
that directory.
Other major areas of improvement: secure string functions,
robust mutexes (mutex in shared memory, lock held by a crashing process
will be put in limbo state for another process to clean up).
Bill: There is no guidance in the C++ standard how to splice
C++ locale objects with C locales. That work is probably worth doing.
Ulrich: Every single OS is going into the direction of making locales more explicit and separate objects.
10:41 hrs coffee break
10:54 hrs resume from break
C++ library recent development
Benjamin: C++03, C++0x, and TR paper queues that have or may have POSIX implications.
C++03:
- standard-visible writable static storage-duration objects that may
or may not be made thread-local (e.g. errno) (heritage from the
1970ies)
- standard locale integration with POSIX locales, GNU has an
implementation of C++ locales on top of POSIX Draft3 locale objects,
also consider thread-local locales.
- interaction of exception handling for C++ and POSIX threads
- thread-local storage (POSIX library feature, C __thread keyword); there is a C++ proposal for a language feature
C++0x:
- "system_error" include file, there is a list of issues in the C++ pre-meeting mailing (Ulrich: creates a dependeny on POSIX)
- atomics interface (basically compiler intrinsics: language support library; little interaction with POSIX wrt. error numbers)
- memory model
- C++ API to POSIX threading API
- random numbers
TR2:
- filesystem library
- network library
Modules TR:
- dlopen, also interactions of threads and shared libraries (for example, constructors/destructors of thread-local storage)
Review of current threading ideas, APIs, and other approaches to parallelism.
WG21 N2320: Threading API
- Howard: C and C++ interact on mutex lock and unlock, difficulties
with cancellation starting with the premise that C++ cancellation is an
exception. C++ is not in a position to mandate that we break C ABIs by
mandating propagating exceptions through C stackframes.
- Ulrich: Every single ABIs nowadays requires exceptions propagation
support everywhere; there is no runtime overhead required if you
implement it correctly.
- Bill: Embedded customers may have problems with exceptions, thus
it may not be a good idea to expose cancellation as exceptions on the
lowest level.
- Howard: Apple engineers do not know how to propagate exceptions
through 32bit C stackframes right now without breaking the ABI. We
cannot ask to recompile the universe. The future looks brighter on
64bit platforms. The fear is an old C stackframe calling directly or
indirectly a new C++ stackframe throwing exceptions.
- Bill: It's a question of customer acceptance not to break ABIs.
- Jason: POSIX could specify a language-independent exception architecture.
- Eric: ... or mandate that C propagate exceptions.
- Ulrich: Separating concerns and versioning may alleviate the issues.
- Ulrich: Threads therefore should not be in the C++ language, instead it should be in the POSIX/C++ binding.
- Everything in the C or C++ standard has to be implemented globally, which practically means at least Windows and POSIX.
- Howard: C interface is missing from C++ proposal to give the C committee the opportunity to break the ABI.
- Ulrich: Inter-process shared memory communications are an absolute requirement for POSIX.
- Bill: C++ has deviated from 5+ years of boost.threads customer experience.
- Howard: Closest proposal to Boost while implemented the features (in particular cancellation) that the C++ committee asked for.
Benjamin: Higher-level C++ APIs for threading (no papers exist yet
for either WG21 or POSIX), by creating a parallel STL: Take algorithms
such as count, find, etc. from the STL and make them internally
parallel, also for_each. The work is pioneered by Intel. This suggests
another area of C++ work, for example for a TR.
Ulrich: This is the right level for an approach to parallelism
in the C++ language, putting something more low-level in (i.e. an OS
binding) is not the right level.
Tana: It's important not to fracture the C++ committee, because it's very diverse.
Ulrich: On the Sun platform, POSIX threads has dominated Sun threads for a lot of years.
Howard: There is pressure to ship C++0x with a threading API,
joint EWG+LWG groups want futures and thread-pools, overruling library
working group.
Bill: There is a lot of political manouverings going on in WGs. Higher-level thread concepts were sponsored by Herb and Bjarne.
Lawrence: A TR that changes the ABI is a non-starter. Some TR
features require core language features, but those core language
features will only be exercised by the TR features, and you can't fix
the core language features in the TR.
Bill: The argument was that not providing thread pools in the standard, everybody will create their own incompatible version.
Ulrich: C++ will have the same problems as Java, eventually failing to provide interoperability.
Lawrence: "It's not going to work" is not going to convince the C++ committee, you need to name specific technical issues.
12:00 hrs lunch break
13:43 hrs resume from lunch break
Review of Evaluation Criteria
Now discussing N001, the annotated PASC PMC PAR Evaluation Criteria.
Target audience is IEEE (Institute of Electrical and Electronics
Engineers) PASC (portable applications standards committee) SEC
(sponsor executive committee).
1. Industry experience
- Howard: Boost is existing practice.
- Ulrich: Industry practice does not mean we have to have a 100%
match, it means we have to have experience with the given
functionality.
- Bill: Dinkumware is shipping a threading library and an extended locale library.
- There are a number of sockets libraries for C++, e.g. ASIO, ACE, Socket++, Stone3.
- Benjamin: GNU has extended locales, too.
2. Base document
- Not just refer to C++ draft, also refer to C++ documents which are not yet voted into the working draft.
- N2058 Proposed Text for Proposal to add Date-Time to the Standard Library 1.0, N2071 Iostream manipulators for convenient extraction and insertion of struct tm objects, and N1975 Filesystem Library Proposal for TR2 (Revision 3) are intended for TR2
- N2175 Networking Library Proposal for TR2 (Revision 1)
- N1976 dynamic shared objects
- N2044 memory mapped files and shared memory for C++
- N2320 Multi-threading Library for Standard C++
- N2117 Minimal Dynamic Library Support
- N2300 Concurrency memory model (revised)
- N2316 Modules in C++ (Revision 5)
- N2324 C++ Atomic Types and Operations
- N2325 Dynamic Initialization and Destruction with Concurrency
- N2328 Proposal for Date-Time Types in C++0x To Support Threading APIs
- N2321 Enhancing the time_get facet for POSIX® compatibility, Revision 2
- N2186 Some Small Additions to iostream
5. Coordination plan
- Nick: How do we coordinate with the other things that are going
on? How is the POSIX/C++ bindings group to interact with WG21? Where
does the work happen? How do we make sure we don't end up with
competing threads libraries?
- Howard: As the chair of the C++ library working group, tries to proceed in a manner as open as possible.
- Nick: Will do some of that, as a duty to SC22.
- Lawrence: Keeping an eye out.
- Ulrich: Make sure we cover the full POSIX/C binding wrt. the C++ binding.
- Don: This process is ending into an ISO work item.
- Nick, Ulrich: Ideally, POSIX extends ISO C and makes it more
specific in areas where ISO C is implementation-defined or unspecified.
- Ulrich: Use C++ interfaces as-is unconditionally and modify and extend it?
- Ulrich: Due to the C++ timeline, there will be no overlap between
POSIX/C++ and WG21's work on C++0x, since WG21 intends to vote out a
feature-complete standard in October.
- Lawrence: The best way to coordinate is to have people that attend both groups.
- Nick will, but doesn't want to be the only one.
- Nick: Somebody from the library group should present the C++
threading stuff to the Austin group. The Austin Group meets in Reading,
UK, next to the train station in September 4th to 7th (Tuesday to
Friday lunch).
- Howard cannot volunteer himself, but Lois and/or Alisdair Meredith
is in the UK and will probably spare a few hours. Presenter must not
necessarily have answers, but should take note of all concerns. Howard
can spare two hours on the telephone, but has to coordinate with
private duties.
- Ulrich: liason officials?
- Nick: There is a lot of organizational overlap between POSIX and
C++, probably all POSIX member organizations are also part of the WG21
C++ effort.
- Don: If we don't come out of this meeting with Evaluation Criteria and PAR, the POSIX/C++ effort is effectively dead.
- Nick: Assuming we want to continue with POSIX/C++, we strive to
schedule it adjacent to WG21 meetings to get enough
coverage/attendance.
3. Realistic scope and timeline
- Nick: Timeline was conjured out of thin air.
- Ulrich: Realistically, the project will not start before early next year.
- Ulrich: suggest: document outline: Q3/2008, draft 1: Q1/2009, first ballot: Q1 2010, final ballot: Q2/2011
- Ulrich: The technical editor (a paid OpenGroup employee) gets finished text, fixes only English and formatting.
- Ulrich Is the timeone realistic?
- Nick: Once the PAR gets approved, a 5-year clock starts ticking.
After that, you can request a one-year extension with good arguments.
After that, requirements on arguing for additional extensions increase
significantly.
- Tom: Motivating POSIX people to get involved is good. If it competes for resources with C++, there may be political issues.
- Nick: If we would build on C++03, POSIX/C++ would have to do a lot
more work. If more stuff is in C++0x, it's much easier for us.
- Michael Wong: Delay until C++0x is complete, because we're building on it?
- Nick: We want to make sure C++0x is doing the right thing.
- Ulrich: There is a need today for the technology.
- Lawrence: The worst outcome would be not knowing that we screwed up. That would be worse that deliberately screwing up.
- Nick: We probably need a lot more drafts and more ballots.
- Don: 1003.1, 1003.2 ballots were on draft 13.
4. Appropriateness and industry acceptance
Ok.
6. Community commitment
- Howard: Change "Metrowerks" to "Apple".
- Tom Plum: Add "Plum Hall" to "confirmed participation" list.
- Bill: Add "Dinkumware".
- Nick: need Chair, Co-Chair, Secretary, Editor
- Nick volunteers for Secretary.
- Benjamin: volunteers for secretary or co-chair, assuming there is a chair
- Maybe take someone from POSIX to balance out Benjamin (choice: Mark, Don, Larry, Ulrich)
- Don: C++ expertise is not strong enough for this project.
- Tom: Benjamin should get administrative support from Red Hat?
- Nick: Chair has to run the meetings, come up with the agenda, etc.
- Have Ulrich as the other co-chair? Needs coordination with Red Hat management.
- But Benjamin and Ulrich are both from Red Hat.
- Nick is willing to help with the procedural issues.
- Current tentative plan: Ulrich as chair (because he is an IEEE member), Benjamin as vice-chair, Nick as secretary.
7. Within PASC scope
Yes.
8. Reasonable resource impact
Nick: We shouldn't drain resources from C++ nor POSIX.
Agreed on the words.
9. Test plan
No test specifications.
15:09 hrs coffee break
15:19 hrs resume from coffee break
Review of PAR form
Now discussing N002, the PAR form.
4.1: Can have individual (per-person) or organizational voting.
4.2: Expected Date of Submission for Initial Sponsor Ballot: March 2010
4.3: Projected Completion Date for Submittal to RevCom: June 2011
5.1: Approximate number of people expected to work on this project: 15
5.2: Scope of Proposed Standard
- Nick: This is used by the ballot group to determine whether the working group has done its job.
- Ulrich: Replace "API" by "functionality"
- Nick: if ISO C++ interfaces overlap, extend the interfaces rather than provide alternatives.
- Jens: defer to POSIX/C where POSIX/C provides all the benefits, no C++ binding has to be provided.
- Thomas Witt: is this sufficiently precise?
- Tom Plum: Integrating C++ with POSIX/C cancellation is a problem.
However POSIX/C deals with cancellation from a C point-of-view.
- Ulrich: add "interoperability between POSIX/C++ binding and POSIX/C binding".
- Hans: possibly provide for enough leeway to extend POSIX/C to allow interoperability
- Ulrich: may include additional interfaces and additional
requirements on POSIX/C to aid in conflict resolution between C, C++,
and POSIX
- Nick: POSIX/C++ thus may prescribe certain features of POSIX/C for
purposes of proper interaction across C++, C, and POSIX. If done so and
WG21 also puts that into C++, this will send a strong message to the C
committee.
- Ulrich: The situation is probably easy for atomics, it needs much more arguing for propagating exceptions.
5.3: Is the completion of this standard is dependent upon the completion of another standard?
- Ulrich: add dependency on C++09
5.4: Purpose of Proposed Standard (the "why" question)
- Nick: mixed-language (C and C++) programs
- Ulrich: Also describe the C++ equivalent of "c99" (i.e. how to call the C++ compiler)?
- Ulrich: There are other utilities: should "yacc" create C++-safe code? Also getconf?
- Ulrich: The "main" environment may not necessarily be POSIX
conformant, thus provide a way to compile and link a conforming
application.
- Tom Plum: The marketplace for strict conformance C++ compilers is not large.
- This Study Group agrees not to include changes to the utilities
section, including how to invoke the C++ compiler, in the current PAR,
notwithstanding the possibility to revisit the issue prior to
completing the POSIX/C++ binding standards project.
5.5: Need for the project
5.6 Stakeholders for the standard
- add BSD, Dinkumware, IBM.
- Lawrence: add "C++ vendors"
- consensus: remove company names
6.1 Intellectual Property
- Nobody in the room is aware of non-expired patents concerning either POSIX or C++.
- Copyright permissions: Needed for POSIX and C++ standards.
- No registration activity.
7.1 Are there other standards or projects with similar scope?
- Nick: Simplify the sentence, add overlap with C++0x and possibly
the next C revision. Commitment to interoperate with the relevant
committees.
- add ISO 14882:2003
7.2 Future adoption
7.3 health, safety, security, environmental
Consensus on the answers to the PAR form.
Introduction to C++ threads API proposals (Howard Hinnant)
- Ulrich: Difference between std::thread and thread-id will cause
problems; due to unique ownership of std::thread. No benefit here. With
thread-ids, several threads may concurrently join/detach, calls other
than the first will receive an error, which is perfectly valid use.
- Hans Boehm: The thread-id may be reused after the thread terminated after join/detach.
- Ulrich: joinable() not implementable in POSIX, needs additional state in the std::thread wrapper class.
- Ulrich: If you want to go back from a native thread handle (pthread_t) to std::thread (currently not possible), then joinable()
- Don: In a mixed C/C++ application, you cannot guarantee that there is only a single join etc.
- Bill: In a mixed C/C++ application, you better manipulate threads with POSIX/C only.
- Don: Need rules for interaction between POSIX/C and POSIX/C++, similar to the rules for FILE* and file descriptors.
- Ulrich: A pthread_join() on the pthread_t is not visible to the C++ thread class.
- Tom Plum: With work on the atomics, can you make C++ thread objects accessible from C?
- Lawrence: C may interact with C++ threads, not necessarily POSIX/C.
- Ulrich: doesn't have answers, but just notices problem.
- Howard: better analogy is FILE* vs. C++ iostreams
- Ulrich: The language should be concerned with high-level concepts, POSIX/C++ should define the OS thread implementation.
Thank the host by acclamation.
Meet at the Primrose room today at 20:00 hrs, fed and watered, for further informal discussion.
Meet in the hotel lobby on Monday at 8:30 hrs for people who want to walk to the IBM facility together.
Adjourned the meeting at 17:09 hrs.
Additional informal evening meeting
Primrose room at Hilton Hotel.
Start at 20:05 hrs
- cancellation
- type unification
- interoperation of C/C++ interfaces
- memory/lock model
Interaction of shared libraries and thread-local storage
- constructors and destructors for thread-local storage and dlopen:
- Ulrich: you cannot interrupt any other thread to invoke the constructors
- Lawrence: two solutions: prohibit non-PODs in thread-local
storage, or delay the construction by adding checks in all functions
that use a given thread-local non-POD variable
- Thomas Witt: the added checks don't bother me, because you only pay when you use the feature
- Ulrich: Handling destructors also adds overhead, need to have a separate list for each shared library.
- Ulrich: lowest overhead is to only run constructors for thread-local variables in the one thread that performs the dlopen
- Jason: How can you hope to run the destructors at dlclose time for
every thread? You cannot, same argument as with constructors.
- Lawrence: Effect of demand-loaded shared libraries on the ODR has to be explored.
- Ulrich: Cannot delay running the destructors of thread-local
variables, because the destructor code disappears from the address
space.
- Lawrence: In the case of global data (not thread-local storage),
you may want to call a virtual destructor in a shared library that was
already unloaded.
Thread creation API (Howard)
- When destructing a "std::thread t(f)", what should we do?
- option 1: t.join()
- option 2: t.detach() (boost)
- option 3: cancel
- option 4: cancel + detach (N2320)
- option 5: cancel + join
- Ulrich: In order to make the resource go away, you need to use join()
- Hans: if you detach, you cannot kill off the thread on process shutdown before running destructors of global variables
- consensus to strike option 3, because it leaks thread return value memory / status
- Ulrich, Lawrence, Jason prefer option 5, much cleaner
- Ulrich: have a separate argument to the thread constructor to choose between option 1 and option 5
- Nick / Howard: have an enum for options 1-5 (except 3)
- Howard: can think of use cases of all options 1-5 excl. 3
- Howard: would like a scope guard to configure thread exit behavior, e.g. std::unique_ptr with deleter policy
- Benjamin: Penalizing the common case?
- Howard: choose the best default we can, make that the default, and provide the unique_ptr path for the non-default behavior
- Benjamin: prefers a policy-based thread class
- Howard: makes the thread classes different types, screws up homogenous containers
- Howard: want a fairly low-level std::thread, keep it as simple as possible
- Bjarne: Are any of the scenarios more common for novices? Howard: option 4. Bjarne: make it the default
- Howard: example of leaving a function with 50 sub-threads: option 4 and 5
- Lawrence: option 5 is just a performance problem, option 4 may be a correctness issue
- Nick: The naive use would expect option 5.
- Bjarne: We are in a deep technical discussion. How is the overall design affected by the choice of the default?
- Howard: We have a ~thread, doing something non-trivial.
- Jason: have RAII, not have a copy constructor, have a move constructor (same with assignments)
- Jens: How do you get from a pthread_t to a std::thread object?
- Ulrich: Equate std::thread with pthread_t* ?
- Jason: Prefer to stick with the design in the paper.
- Ulrich: For example, make a std::thread contain a single pthread_t (i.e. bitwise the same as pthread_t), no virtual tables etc.
- Bjarne: We give up virtual functions on std::thread, we dislike separate types, thus the destructor choice must be in data.
- Ulrich: We can assume a cooperative threads library that provides the necessary storage for the join/detach/cancel choice.
- Bjarne: Why don't we use a pointer-to-function instead of the
bool/enum parameter to the constructor for the destructor behavior
choice.
- Lawrence etc.: reinterpret_cast between std::thread and pthread_t is ok with optimizers
- Thomas Witt: unique ownership interacts with this design?
- Bjarne: You get what you get when you mess using the pthread_t and C interfaces.
- Bjarne: It may be good thing to enable to take the representation
of a C++ type and manipulate it in a way that is illegal in plain C++,
for example in a special language for special operations.
- Ulrich: pthreads implementations just use pthread_t as a pointer, can add additional data for destruction
Cancellation
- Howard: In C++, thread cancellation will be an exception. Can't unwind C stackframes on 32bit MacOS.
- Lawrence: It's a migratory change.
- Bjarne: It's an ABI change.
- Jason: compromise position: have a "sticky cancel", if you eat the
cancellation exception, the exception ceases to exist, but the
"cancelled" state sticks around and causes another cancellation
exception at the next cancellation point
- Ulrich: add another cancellation point just after each catch block (for each code path out of the catch block)
- Howard: thread pools: If we cancel a thread operating on a given
function, we can either terminate the thread (and create a new thread
for the thread pool) or catch the cancellation exception and recycle
the thread.
- Howard: If threads are so efficient on creation and destruction, then we don't need thread pools.
- Bjarne: I only want to hand over a function to be executed asynchronously and return the result.
- Howard: Compared thread pools with thread creation / destruction, and it does matter on his platform; Bjarne seconds.
- Ulrich: cancellation in POSIX is a final decision, influences the program assumptions for cancellation handlers
- Lawrence: Cancellation a future = cancellation a thread, why?
- Howard: A future is a some function that is cancellation-aware and needs to perform some cleanup on cancellation.
- Eric: We we just disallow catching a cancellation exception, people are required to write destructors instead.
- Jason, Howard: disagree.
- Nick: POSIX specifies how cancellation works, C++ wants to have
cancellation work differently to address a different community.
- Lawrence: Thread-cancel could be POSIX-style, but canceling a
future could be different, for example throw some other exception.
- Bjarne: Just tell the future "I'm no longer interested".
- Hans Boehm: Is there code that breaks if thread-cancel doesn't terminate the thread?
- Ulrich: Yes. Use an explicit pthread-cleanup handler to free a
dynamic object, the code expects that the dynamic object is never used
again.
- Ulrich: pthread-cancellation handler has to be integrated with C++ cancellation exceptions.
- Howard: We only want to write only one catch block for both future cancellation and thread cancellation.
- Ulrich: do not run pthread cancellation handlers when unwinding upon a future cancellation
- Bjarne: We can't make it impossible to screw up.
- Bjarne: How does a future commit suicide?
- Ulrich: Injecting an exception from the outside is the new issue.
- Jason: Maybe pass an arbitrary exception to a foreign thread?
- Ulrich: thread cancellation is not caught by catch(...)
- Hans Boehm: catch(...) contains cleanup code that needs to run for thread-cancellation, too
- Jason: iostreams are particular offenders using catch(...) to swallow exceptions
- Bjarne: Should we separate future canceling from canceling the future's thread? Didn't hear good arguments in favor.
- Eric: How often do we need to cancel a future? If it is really an
exceptional condition, it's ok to destroy the future's thread and
recreate it, if needed.
- Nick: leave it unspecified.
- Neither of options 1-5 excl. 3 is suitable for thread pool
destruction, you want to do "cancel, cancel, cancel, ..." and then join
everybody.
- Jens: We did not get rid of "sticky cancel", we just got rid of
injecting arbitrary exception into foreign threads (at cancellation
points).
- Jason: sticky cancels supports catching cancellation exceptions by catch(...)
22:41 hrs finish.