Conversation
|
@bnoordhuis What do you think? |
|
The first two commits look okay to me but the last one results in an unpleasant amount of code duplication.
A binding.gyp can override that (ditto for {
'cflags_cc!': ['-std=gnu++1y'],
'cflags_cc': ['-std=c++17'],
'xcode_settings': {
'CLANG_CXX_LANGUAGE_STANDARD': 'c++17',
},
# ..
}But as to You can use exceptions in add-ons (and some do) but they should never ever escape into code compiled without exception support. |
The problem is that this is the only way to maintain backwards compatibility, i.e. not force users to use C++17.
I think it's always better to throw an exception instead of just calling As nan is a header only library, it should imho be left to the users to decide whether they want exceptions or not. I think that, at the moment, if no memory can be allocated (which usually never happens), But from what I read, it might be worth creating and maintaining a |
Just to be clear, nan takes no position on the use of exceptions.
Speaking for myself (not other maintainers), I have no interest in maintaining such a fork at the moment. I expect that most new add-ons will be written using n-api, not nan. That's not to discourage you, of course. You're welcome to start that fork. |
Of course I'd maintain the C++17 fork, should've mentioned that in the first place! What I was trying to say is that I would much appreciate if it's possible to modularise the nan.h header a bit so that it's easier for me to maintain the fork (i.e. avoid the "merge-hell")... |
|
I'm open to that if it's not too much maintenance and review work. What plan of attack do you propose? |
|
Perhaps something based on the documentation along with the pre-0.12 / post-0.12 split? |
2281ee7 to
1026683
Compare
…d Mac. Fix bug in C++17 worker
This PR aims to improve the existing Async Workers using C++17 features
For the time being, only AsyncProgressQueueWorker was improved.
The improvements include
unique_ptr) to prevent memory leaks in case of exceptionsstd::aligned_allocandstd::uninitialized_copy, which remove the necessity of the MessageStruct being default constructiblestd::mutexinstead of libuv's mutexes and lock_guard to prevent locking forever in case of error)std::unique_ptr)As mentioned above, the legacy API
SendProgress_(const T * const messages, const size_t nMessages)is still supported (but marked as deprecated). Therefore, this works as a drop-in replacement even for C++17.Additionally, the unmodified legacy workers are still there and used if the C++ version is below C++17.
This is not ready to merged yet for some reasons:
-std=gnu++1y, but C++17 is required for thisstd::bad_allocexception should be thrown in case of error, but the node headers force-fno-exceptions