worker_builder.h
1 
5 #pragma once
6 
7 #include <memory>
8 #include <utility>
9 
10 namespace ucxx {
11 
12 // Forward declarations
13 class Context;
14 class Worker;
15 
16 namespace experimental {
17 
43  private:
44  std::shared_ptr<Context> _context;
45  bool _enableDelayedSubmission{false};
46  bool _enableFuture{false};
47 
48  public:
54  explicit WorkerBuilder(std::shared_ptr<Context> context);
55 
62  WorkerBuilder& delayedSubmission(bool enable = true);
63 
70  WorkerBuilder& pythonFuture(bool enable = true);
71 
80  std::shared_ptr<Worker> build() const;
81 
91  operator std::shared_ptr<Worker>() const;
92 };
93 
122 inline WorkerBuilder createWorker(std::shared_ptr<Context> context)
123 {
124  return WorkerBuilder(std::move(context));
125 }
126 
127 } // namespace experimental
128 
129 } // namespace ucxx
Builder class for constructing std::shared_ptr<ucxx::Worker> objects.
Definition: worker_builder.h:42
WorkerBuilder & pythonFuture(bool enable=true)
Configure Python future support.
WorkerBuilder & delayedSubmission(bool enable=true)
Configure delayed submission to the progress thread.
std::shared_ptr< Worker > build() const
Build and return the Worker.
WorkerBuilder(std::shared_ptr< Context > context)
Constructor for WorkerBuilder with required context.
Definition: address.h:15
std::shared_ptr< Worker > createWorker(std::shared_ptr< Context > context, const bool enableDelayedSubmission, const bool enableFuture)
Constructor of shared_ptr<ucxx::Worker> with parameters.