# dds-bridge-sys
[](https://github.com/jdh8/dds-bridge-sys)
[](https://crates.io/crates/dds-bridge-sys)
[](https://docs.rs/dds-bridge-sys)
Generated bindings to [dds-bridge/dds](https://github.com/dds-bridge/dds),
the C++ double dummy solver for contract bridge.
## Usage
This library needs manual initialization! Initialize the thread pool with
[`SetMaxThreads`](https://docs.rs/dds-bridge-sys/latest/dds_bridge_sys/fn.SetMaxThreads.html)
before calling other library functions:
```rust
use dds_bridge_sys as dds;
// 0 stands for automatic configuration
unsafe { dds::SetMaxThreads(0) };
```
Also note that functions using the thread pool are not reentrant. You may want
to use a mutex to ensure that only one thread is using the thread pool.
For a higher-level safe wrapper, see the [`dds-bridge`](https://crates.io/crates/dds-bridge)
crate, whose [`Solver`](https://docs.rs/dds-bridge/latest/dds_bridge/solver/struct.Solver.html)
type manages the mutex for you.
## Thread Safety
Functions fall into four categories:
### Non-reentrant — exclusive thread-pool access required
These functions drive the internal thread pool and must not be called
concurrently. Protect all calls with a single mutex:
- [`CalcDDtable`] / [`CalcDDtablePBN`] — compute a full DD table (threads per strain)
- [`CalcAllTables`] / [`CalcAllTablesPBN`] — batch DD tables
- [`SolveAllBoards`] / [`SolveAllBoardsBin`] — batch board solving
- [`SolveAllChunksBin`] / [`SolveAllChunksPBN`] (deprecated aliases)
- [`AnalyseAllPlaysBin`] / [`AnalyseAllPlaysPBN`] — batch play analysis
### Reentrant — explicit `threadIndex` parameter
These are safe to call from multiple threads simultaneously. Each concurrent
call must use a distinct `threadIndex` in `0..SetMaxThreads(0)`.
- [`SolveBoard`] / [`SolveBoardPBN`]
- [`AnalysePlayBin`] / [`AnalysePlayPBN`]
### Always safe — no thread pool involved
- Par: [`Par`], [`CalcPar`], [`CalcParPBN`], [`SidesPar`], [`DealerPar`],
[`DealerParBin`], [`SidesParBin`]
- Text: [`ConvertToDealerTextFormat`], [`ConvertToSidesTextFormat`]
- Utilities: [`GetDDSInfo`], [`ErrorMessage`]
### Thread-pool management
Call one of the following once at startup before any other function:
- [`SetMaxThreads`] — initialize (`0` = auto-configure)
- [`SetResources`] — set memory and thread limits