Skip to content

Commit 008d415

Browse files
committed
Update README.md
1 parent 8383f49 commit 008d415

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
- [Sponsors](#sponsors)
1616
- [Integration](#integration)
1717
- [C++ Version](#c-version)
18+
- [Threading Modes](#threading-modes)
19+
- [Emscripten / WebAssembly](#emscripten--webassembly)
1820
- [Single Header](#single-header)
1921
- [CMake Instructions](#cmake-instructions)
2022
- [Avoid cloning with FetchContent](#avoid-cloning-with-fetchcontent)
@@ -124,6 +126,28 @@ While C++17 is recommended, C++11 is the minimum version required. This library
124126
125127
This library requires C++ exceptions to be enabled (for example, do not compile with `-fno-exceptions`).
126128
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+
#define CSV_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+
127151
### Single Header
128152
**[📥 Download csv.hpp](https://vincentlaucsb.github.io/csv-parser/csv.hpp)** — Available on GitHub Pages
129153
@@ -141,6 +165,10 @@ and add the following to your CMakeLists.txt:
141165
```
142166
# Optional: Defaults to C++ 17
143167
# set(CSV_CXX_STANDARD 11)
168+
169+
# Optional: disable background parsing threads
170+
# set(CSV_ENABLE_THREADS OFF)
171+
144172
add_subdirectory(csv-parser)
145173
146174
# ...

0 commit comments

Comments
 (0)