32#ifndef SC_RUNNABLE_INT_H
33#define SC_RUNNABLE_INT_H
51# define DEBUG_MSG(NAME,P,MSG) \
53 if ( P && ( (std::strlen(NAME)==0) || !std::strcmp(NAME,P->name())) ) \
54 std::cout << "**** " << sc_time_stamp() << " (" \
55 << sc_get_current_process_name("** NONE **") << "): " << MSG \
56 << " - " << P->name() << std::endl; \
59# define DEBUG_MSG(NAME,P,MSG)
79#define SC_NO_METHODS m_methods_push_head
80#define SC_NO_THREADS m_threads_push_head
92 std::cout <<
"thread pop queue: " << std::endl;
94 p = p->next_runnable() )
96 std::cout <<
" " << p << std::endl;
99 std::cout <<
"thread push queue: " << std::endl;
103 std::cout <<
" " << p << std::endl;
116 DEBUG_MSG(DEBUG_NAME,method_h,
"pushing this method to execute next");
117 method_h->set_next_runnable( m_methods_pop );
118 m_methods_pop = method_h;
130 DEBUG_MSG(DEBUG_NAME,thread_h,
"pushing this thread to execute next");
131 thread_h->set_next_runnable( m_threads_pop );
132 m_threads_pop = thread_h;
144 if ( !m_methods_push_head )
148 m_methods_push_head->dont_initialize(
true);
149 m_methods_push_head->detach();
152 m_methods_push_tail = m_methods_push_head;
155 if ( !m_threads_push_head )
159 m_threads_push_head->dont_initialize(
true);
160 m_threads_push_head->detach();
164 m_threads_push_tail = m_threads_push_head;
175 return m_methods_push_head->next_runnable() ==
SC_NO_METHODS &&
189 return m_methods_push_head && m_threads_push_head;
203 DEBUG_MSG(DEBUG_NAME,method_h,
"pushing back method");
205 m_methods_push_tail->set_next_runnable(method_h);
206 m_methods_push_tail = method_h;
220 DEBUG_MSG(DEBUG_NAME,thread_h,
"pushing back thread");
222 m_threads_push_tail->set_next_runnable(thread_h);
223 m_threads_push_tail = thread_h;
238 DEBUG_MSG(DEBUG_NAME,method_h,
"pushing front method");
239 method_h->set_next_runnable(m_methods_push_head->next_runnable());
240 if ( m_methods_push_tail == m_methods_push_head )
242 m_methods_push_tail->set_next_runnable(method_h);
243 m_methods_push_tail = method_h;
247 m_methods_push_head->set_next_runnable(method_h);
263 DEBUG_MSG(DEBUG_NAME,thread_h,
"pushing front thread");
264 thread_h->set_next_runnable(m_threads_push_head->next_runnable());
265 if ( m_threads_push_tail == m_threads_push_head )
267 m_threads_push_tail->set_next_runnable(thread_h);
268 m_threads_push_tail = thread_h;
272 m_threads_push_head->set_next_runnable(thread_h);
286 result_p = m_methods_pop;
289 m_methods_pop = result_p->next_runnable();
290 result_p->set_next_runnable(0);
296 DEBUG_MSG(DEBUG_NAME,result_p,
"popping method");
311 result_p = m_threads_pop;
314 m_threads_pop = result_p->next_runnable();
315 result_p->set_next_runnable(0);
321 DEBUG_MSG(DEBUG_NAME,result_p,
"popping thread for execution");
345 prior_p = m_methods_push_head;
346 for ( now_p = m_methods_push_head->next_runnable(); now_p!=
SC_NO_METHODS;
347 now_p = now_p->next_runnable() )
349 if ( remove_p == now_p )
351 prior_p->set_next_runnable( now_p->next_runnable() );
352 if (now_p == m_methods_push_tail) {
353 m_methods_push_tail = prior_p;
355 now_p->set_next_runnable(0);
356 DEBUG_MSG(DEBUG_NAME,now_p,
"removing method from push queue");
366 now_p = now_p->next_runnable() )
368 if ( remove_p == now_p )
371 prior_p->set_next_runnable( now_p->next_runnable() );
373 m_methods_pop = now_p->next_runnable();
374 now_p->set_next_runnable(0);
375 DEBUG_MSG(DEBUG_NAME,now_p,
"removing method from pop queue");
402 prior_p = m_threads_push_head;
403 for ( now_p = m_threads_push_head->next_runnable(); now_p !=
SC_NO_THREADS;
404 now_p = now_p->next_runnable() )
406 if ( remove_p == now_p )
408 prior_p->set_next_runnable( now_p->next_runnable() );
409 if (now_p == m_threads_push_tail) {
410 m_threads_push_tail = prior_p;
412 now_p->set_next_runnable(0);
413 DEBUG_MSG(DEBUG_NAME,now_p,
"removing thread from push queue");
423 now_p = now_p->next_runnable() )
425 if ( remove_p == now_p )
428 prior_p->set_next_runnable( now_p->next_runnable() );
430 m_threads_pop = now_p->next_runnable();
431 now_p->set_next_runnable(0);
432 DEBUG_MSG(DEBUG_NAME,now_p,
"removing thread from pop queue");
445 m_methods_push_head(0), m_methods_push_tail(0), m_methods_pop(
SC_NO_METHODS),
446 m_threads_push_head(0), m_threads_push_tail(0), m_threads_pop(
SC_NO_THREADS)
456 delete m_methods_push_head;
457 delete m_threads_push_head;
471 m_methods_pop = m_methods_push_head->next_runnable();
473 m_methods_push_tail = m_methods_push_head;
488 m_threads_pop = m_threads_push_head->next_runnable();
490 m_threads_push_tail = m_threads_push_head;
#define DEBUG_MSG(NAME, P, MSG)
class sc_method_process * sc_method_handle
class sc_thread_process * sc_thread_handle
void(sc_process_host::* sc_entry_func)()
void push_front_thread(sc_thread_handle)
void execute_thread_next(sc_thread_handle)
void remove_method(sc_method_handle)
void push_back_thread(sc_thread_handle)
void execute_method_next(sc_method_handle)
void remove_thread(sc_thread_handle)
bool is_initialized() const
void push_back_method(sc_method_handle)
void push_front_method(sc_method_handle)
sc_method_handle pop_method()
sc_thread_handle pop_thread()