You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Rough draft of Emscripten and single threaded support
* Use different classes for CSVRow deques
* Disable threads automatically for Emscripten
* Update basic_csv_parser.hpp
Fix Emscripten failure
* Update CMakeLists.txt
* Update csv_row.hpp
Reduce duplication
* More clean-up
* Auto-disable threads if not detected
* Fixed version detection macro
* Final polish
* Run emscripten tests
* Very minor BasicCSVParser constructor fix
* Documentation updates
* Update README.md
* Fix CI failures
* Disable file-reading tests for Emscripten suite
* Minor issues
* Fix test failures
* Added more file guards
* Added more guards
* Update test_edge_cases_large_rows.cpp
* Disable Emscripten tests for now
Copy file name to clipboardExpand all lines: AGENTS.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,5 +73,6 @@ ThreadSafeDeque<CSVRow>
73
73
3. **Don't use uniform values:** Each column needs distinct values to detect corruption.
74
74
4. **Don't ignore async:** Worker thread means exceptions must use `exception_ptr`.
75
75
5. **Don't change one constructor:** Likely affects both mmap and stream paths.
76
+
6. **Don't delete or simplify comments** unless they are trivially obvious (e.g. `// increment i`) or factually incorrect. Comments in this codebase frequently encode concurrency invariants, non-obvious design decisions, and hard-won bug context that cannot be recovered from the code alone.
76
77
77
78
See `tests/AGENTS.md` for test strategy, checklist, and conventions.
-[Avoid cloning with FetchContent](#avoid-cloning-with-fetchcontent)
@@ -124,6 +126,30 @@ While C++17 is recommended, C++11 is the minimum version required. This library
124
126
125
127
This library requires C++ exceptions to be enabled (for example, do not compile with `-fno-exceptions`).
126
128
129
+
### Threading Modes
130
+
By default, `csv-parser` uses a background thread to parse file-based input. If CMake cannot find a thread library, threading is disabled automatically.
131
+
132
+
You can also disable it explicitly:
133
+
134
+
**CMake**
135
+
```cmake
136
+
set(CSV_ENABLE_THREADS OFF)
137
+
add_subdirectory(csv-parser)
138
+
```
139
+
140
+
**Non-CMake (define the macro before any csv-parser header)**
141
+
```cpp
142
+
#defineCSV_ENABLE_THREADS 0
143
+
#include "csv.hpp"
144
+
```
145
+
146
+
Single-threaded mode is useful for embedded targets, environments where `std::thread` is unavailable, and WebAssembly builds without pthreads. The public API is unchanged; parsing simply runs synchronously on the caller's thread.
147
+
148
+
### Emscripten / WebAssembly
149
+
On Emscripten, `CSV_ENABLE_THREADS` is forced off and memory-mapped parsing is replaced by the stream-based parser. The filename constructor (`CSVReader("file.csv")`) still works—it opens an `std::ifstream` internally instead of using mmap.
150
+
151
+
Emscripten builds must keep C++ exceptions enabled. In practice, compile/link with exception support (for example, `-fexceptions`) and do not disable exception catching.
152
+
127
153
### Single Header
128
154
**[📥 Download csv.hpp](https://vincentlaucsb.github.io/csv-parser/csv.hpp)** — Available on GitHub Pages
129
155
@@ -141,6 +167,10 @@ and add the following to your CMakeLists.txt:
0 commit comments