3232#include < arrow-glib/scalar.hpp>
3333#include < arrow-glib/schema.hpp>
3434#include < arrow-glib/table.hpp>
35+ #include < arrow-glib/thread-pool.hpp>
3536#include < arrow-glib/type.hpp>
3637
3738#include < arrow/acero/exec_plan.h>
@@ -276,6 +277,7 @@ garrow_compute_initialize(GError **error)
276277typedef struct GArrowExecuteContextPrivate_
277278{
278279 arrow::compute::ExecContext context;
280+ std::shared_ptr<arrow::internal::ThreadPool> thread_pool;
279281} GArrowExecuteContextPrivate;
280282
281283G_DEFINE_TYPE_WITH_PRIVATE (GArrowExecuteContext, garrow_execute_context, G_TYPE_OBJECT)
@@ -289,6 +291,7 @@ garrow_execute_context_finalize(GObject *object)
289291{
290292 auto priv = GARROW_EXECUTE_CONTEXT_GET_PRIVATE (object);
291293 priv->context .~ExecContext ();
294+ priv->thread_pool .~shared_ptr ();
292295 G_OBJECT_CLASS (garrow_execute_context_parent_class)->finalize (object);
293296}
294297
@@ -297,6 +300,7 @@ garrow_execute_context_init(GArrowExecuteContext *object)
297300{
298301 auto priv = GARROW_EXECUTE_CONTEXT_GET_PRIVATE (object);
299302 new (&priv->context ) arrow::compute::ExecContext (arrow::default_memory_pool (), nullptr );
303+ new (&priv->thread_pool ) std::shared_ptr<arrow::internal::ThreadPool>;
300304}
301305
302306static void
@@ -309,15 +313,23 @@ garrow_execute_context_class_init(GArrowExecuteContextClass *klass)
309313
310314/* *
311315 * garrow_execute_context_new:
316+ * @thread_pool: (nullable): A #GArrowThreadPool or %NULL.
312317 *
313318 * Returns: A newly created #GArrowExecuteContext.
314319 *
315320 * Since: 1.0.0
316321 */
317322GArrowExecuteContext *
318- garrow_execute_context_new (void )
323+ garrow_execute_context_new (GArrowThreadPool *thread_pool )
319324{
320325 auto execute_context = g_object_new (GARROW_TYPE_EXECUTE_CONTEXT, NULL );
326+ auto priv = GARROW_EXECUTE_CONTEXT_GET_PRIVATE (execute_context);
327+
328+ auto arrow_thread_pool = garrow_thread_pool_get_raw (thread_pool);
329+ priv->thread_pool = arrow_thread_pool;
330+ new (&priv->context )
331+ arrow::compute::ExecContext (arrow::default_memory_pool (), arrow_thread_pool.get ());
332+
321333 return GARROW_EXECUTE_CONTEXT (execute_context);
322334}
323335
0 commit comments