14 #include "xrubythread.h"
16 XRubyThread::XRubyThread(
const char *name,
bool runtime,
const XString &filename)
17 :
XNode(name, runtime),
21 m_lineinput(create<
XStringNode>(
"LineInput", true)),
22 m_threadID(create<
XLongNode>(
"ThreadID", true)) {
25 tr[ *m_threadID] = -1;
26 tr[ *m_filename] = filename;
27 tr[ *m_action] = RUBY_THREAD_ACTION_STARTING;
28 tr[ *m_status] = RUBY_THREAD_STATUS_STARTING;
29 tr[ *lineinput()].setUIEnabled(
false);
31 m_lsnOnLineChanged = tr[ *lineinput()].onValueChanged().connectWeakly(shared_from_this(),
32 &XRubyThread::onLineChanged);
37 XRubyThread::isRunning()
const {
38 return (( **m_status)->to_str() == RUBY_THREAD_STATUS_RUN);
41 XRubyThread::isAlive()
const {
42 return (( **m_status)->to_str() != RUBY_THREAD_STATUS_N_A);
46 trans( *m_action) = RUBY_THREAD_ACTION_KILL;
47 trans( *lineinput()).setUIEnabled(
false);
50 XRubyThread::resume() {
51 trans( *m_action) = RUBY_THREAD_ACTION_WAKEUP;
55 XString line = shot[ *lineinput()];
57 m_lineBuffer.push_back(line);
59 tr[ *lineinput()] =
"";
60 tr.unmark(m_lsnOnLineChanged);
67 if( !m_lineBuffer.size()) {
68 lineinput()->setUIEnabled(
true);
71 XString line = m_lineBuffer.front();
72 m_lineBuffer.pop_front();