@@ -1729,10 +1729,37 @@ cass_cluster_set_serial_consistency(CassCluster* cluster,
1729
1729
CassConsistency consistency );
1730
1730
1731
1731
/**
1732
- * Sets the number of IO threads. This is the number of threads
1733
- * that will handle query requests.
1734
- *
1735
- * <b>Default:</b> 1
1732
+ * Sets the number of IO threads. This is the number of dedicated runtime threads
1733
+ * that will resolve driver's futures, handling requests and other IO operations.
1734
+ *
1735
+ * If `num_threads` > 0 is given, the driver will create a dedicated thread pool
1736
+ * with the specified number of threads. This is the recommended way to use the
1737
+ * driver, as it allows the driver to execute tasks in parallel and utilize
1738
+ * multiple CPU cores. Also, this makes the execution of futures eager and
1739
+ * in-background, allowing the main thread to do whatever it wants concurrently
1740
+ * with the futures.
1741
+ *
1742
+ * If 0 is specified, the `current_thread` tokio runtime will be used. This runtime
1743
+ * has no dedicated worker threads, but instead uses the current thread to execute
1744
+ * all tasks. This ensures the lowest possible overhead, may make sense for testing
1745
+ * and debugging purposes, or for applications that do not require high concurrency.
1746
+ * Also, single-CPU machines may benefit from this runtime, as operating on a single
1747
+ * thread is usually faster than switching between multiple threads.
1748
+ * **BEWARE:** the semantics of `CassFuture` when `current_thread` runtime is enabled
1749
+ * are different. The futures will not start execution immediately when they are
1750
+ * created, but only when some user thread awaits some future. That is, any thread
1751
+ * that awaits a future will start the execution of all futures that are ready
1752
+ * to be executed at that moment. This means that the only way to ensure that
1753
+ * a future is executed is to await it. On the other hand, if one future is being
1754
+ * awaited, then all other existing futures will be executed in the same thread
1755
+ * until the awaited future is resolved.
1756
+ * A notable example of code that is not compatible with `current_thread` runtime
1757
+ * is the `callbacks` example in this codebase. This is because the main thread
1758
+ * sets up callbacks and then blocks itself on a conditional variable. As no other
1759
+ * thread exists that drives the futures, the callbacks will never be called
1760
+ * and thus the program will hang.
1761
+ *
1762
+ * <b>Default:</b> Number of CPU cores available to the system.
1736
1763
*
1737
1764
* @public @memberof CassCluster
1738
1765
*
0 commit comments