Skip to content

Commit 175e70c

Browse files
committed
Add thread_pool argument to garrow_execute_context_new
1 parent 2140b7d commit 175e70c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

c_glib/arrow-glib/compute.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
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)
276277
typedef struct GArrowExecuteContextPrivate_
277278
{
278279
arrow::compute::ExecContext context;
280+
std::shared_ptr<arrow::internal::ThreadPool> thread_pool;
279281
} GArrowExecuteContextPrivate;
280282

281283
G_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

302306
static 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
*/
317322
GArrowExecuteContext *
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

c_glib/arrow-glib/compute.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <arrow-glib/compute-definition.h>
2323
#include <arrow-glib/datum.h>
2424
#include <arrow-glib/reader.h>
25+
#include <arrow-glib/thread-pool.h>
2526

2627
G_BEGIN_DECLS
2728

@@ -40,7 +41,7 @@ struct _GArrowExecuteContextClass
4041

4142
GARROW_AVAILABLE_IN_1_0
4243
GArrowExecuteContext *
43-
garrow_execute_context_new(void);
44+
garrow_execute_context_new(GArrowThreadPool *thread_pool);
4445

4546
GARROW_AVAILABLE_IN_7_0
4647
gboolean

0 commit comments

Comments
 (0)