31 NamedWorkerThreads::iterator found =
threads_.find (name);
42 for (NamedWorkerThreads::iterator i =
threads_.begin ();
52 NamedWorkerThreads::iterator found =
threads_.find (name);
63 for (NamedWorkerThreads::iterator i =
threads_.begin ();
74 if (name !=
"" && thread != 0)
76 std::unique_ptr<WorkerThread> worker (
new WorkerThread (name, thread,
84 else if (thread != 0 && name ==
"")
89 "Threader::run: named thread has an empty name. Deleting new thread.");
92 "Threader::run: named thread has an empty name. Deleting new thread.");
97 "Threader::run: named thread has an empty name.");
100 "Threader::run: named thread has an empty name.");
108 const std::string name, jobject thread,
bool paused)
110 if (name !=
"" && thread != 0)
117 run (name, new_thread, paused);
124 double hertz,
const std::string name, jobject thread,
bool paused)
126 if (name !=
"" && thread != 0)
133 run (hertz, name, new_thread, paused);
137 #endif // _MADARA_JAVA_ 143 if (name !=
"" && thread != 0)
145 std::unique_ptr<WorkerThread> worker (
new WorkerThread (name, thread,
153 else if (thread != 0 && name ==
"")
158 "Threader::run: named thread has an empty name. Deleting new thread.");
161 "Threader::run: named thread has an empty name. Deleting new thread.");
166 "Threader::run: named thread has an empty name.");
169 "Threader::run: named thread has an empty name.");
176 data_ = std::move(data_plane);
182 NamedWorkerThreads::iterator found =
threads_.find (name);
193 for (NamedWorkerThreads::iterator i =
threads_.begin ();
206 #ifndef _MADARA_NO_KARL_ 207 NamedWorkerThreads::iterator found =
threads_.find (name);
211 std::string condition = found->second->finished_.get_name ();
220 #endif // _MADARA_NO_KARL_ 230 #ifndef _MADARA_NO_KARL_ 231 std::stringstream condition;
233 NamedWorkerThreads::iterator i =
threads_.begin ();
238 condition << i->second->finished_.get_name ();
246 condition << i->second->finished_.get_name ();
251 result = this->
control_.
wait (condition.str (), ws).is_true ();
258 #endif // _MADARA_NO_KARL_ bool is_true(void) const
Checks to see if the record is true.
madara::knowledge::containers::Integer paused
thread safe paused flag that may be set by the Threader
MADARA_EXPORT utility::Refcounter< logger::Logger > global_logger
void terminate(void)
Requests all threads to terminate.
knowledge::KnowledgeBase control_
The control plane used by threads for termination and pause information.
Threader()
Default constructor.
NamedWorkerThreads threads_
the threads that are still active
void run(const std::string name, BaseThread *thread, bool paused=false)
Starts a new thread and executes the provided user thread once.
void pause(void)
Requests all threads to pause.
Abstract base class for implementing threads.
madara::knowledge::KnowledgeRecord wait(const std::string &expression, const WaitSettings &settings=WaitSettings())
Waits for an expression to be non-zero.
knowledge::KnowledgeBase data_
The data plane used by threads.
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers.
A thread that executes BaseThread logic.
This class provides a distributed knowledge base to users.
An exception for general thread-related errors.
void resume(void)
Requests all threads to resume (unpause)
int set(const VariableReference &variable, const std::string &value, const EvalSettings &settings=EvalSettings(false, false, true, false, false))
Atomically sets the value of a variable to a string.
void set_data_plane(knowledge::KnowledgeBase data_plane)
Sets the data plane for new threads.
Encapsulates settings for a wait statement.
bool wait(const std::string name, const knowledge::WaitSettings &ws=knowledge::WaitSettings())
Wait for a specific thread to complete.
A facade for a user-defined Java thread class.
static JavaThread * create(jobject obj)
Creates a JavaThread.