▲ | hinkley 5 days ago | ||||||||||||||||
It uses different threads in order to make infrequent blocking calls look like they are asynchronous. When we (or at least some quantity of “we”) want is infrequent native calls to be able to fail without taking the BEAM down. The problem with doing it with threads though is that a bad thread can still vomit all over working memory, still causing a panic even if it itself doesn’t panic. | |||||||||||||||||
▲ | toast0 5 days ago | parent [-] | ||||||||||||||||
Oh I see. If you need to isolate your native code from your BEAM, then you've got several options. a) run the native code as a separate process; either a port program, a c-node, or just a regular program that you interact with via some interprocess communication (sockets, pipes, signals, a shared filesystem, shared memory segments if you're brave) b) some sort of sandybox thing; like compile to wasm and then jit back to (hopefully) safe native. c) just run the native code, it's probably fine, hopefully. My experience with NIFs is that they are usually very short code that should be easy to review, so this isn't as bad as it sounds... If your native code is short, option c is probably fine; if your native code is long, option a makes more sense. If you want to make things harder without real justification, b sounds good :P | |||||||||||||||||
|