Commit 9cc1ecb
committed
Defer loading the NIF until opening an I2C bus
This change moves the NIF load from the time at which the module is
loaded to the time when I2C actually is used.
The primary motivation for doing this is to defer native code crashes
from happening at load time to the time of first use. Load time is
harder to debug and sometimes its not clear which NIF caused the crash.
The calls to `apply` get around some complexity with ignoring Dialyzer
warnings. Dialyzer can't figure out that the recursive looking call
actually invokes the NIF code.1 parent f75eef8 commit 9cc1ecb
1 file changed
+12
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | 2 | | |
6 | 3 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
15 | 8 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
21 | 12 | | |
22 | 13 | | |
23 | 14 | | |
24 | | - | |
25 | 15 | | |
26 | 16 | | |
27 | 17 | | |
28 | 18 | | |
29 | 19 | | |
30 | 20 | | |
31 | 21 | | |
32 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
33 | 27 | | |
0 commit comments