30 #ifndef SC_RUNNABLE_INT_H
31 #define SC_RUNNABLE_INT_H
47 # define DEBUG_NAME ""
48 # define DEBUG_MSG(NAME,P,MSG) \
50 if ( P && ( (strlen(NAME)==0) || !strcmp(NAME,P->name())) ) \
51 std::cout << "**** " << sc_time_stamp() << " (" \
52 << sc_get_current_process_name() << "): " << MSG \
53 << " - " << P->name() << std::endl; \
56 # define DEBUG_MSG(NAME,P,MSG)
69 #define SC_NO_METHODS ((sc_method_handle)0xdb)
70 #define SC_NO_THREADS ((sc_thread_handle)0xdb)
82 std::cout <<
"thread pop queue: " << std::endl;
84 p = p->next_runnable() )
86 std::cout <<
" " << p << std::endl;
89 std::cout <<
"thread push queue: " << std::endl;
93 std::cout <<
" " << p << std::endl;
106 DEBUG_MSG(DEBUG_NAME,method_h,
"pushing this method to execute next");
107 method_h->set_next_runnable( m_methods_pop );
108 m_methods_pop = method_h;
120 DEBUG_MSG(DEBUG_NAME,thread_h,
"pushing this thread to execute next");
121 thread_h->set_next_runnable( m_threads_pop );
122 m_threads_pop = thread_h;
135 if ( !m_methods_push_head )
139 m_methods_push_head->dont_initialize(
true);
140 m_methods_push_head->detach();
142 m_methods_push_tail = m_methods_push_head;
146 if ( !m_threads_push_head )
150 m_threads_push_head->dont_initialize(
true);
151 m_threads_push_head->detach();
154 m_threads_push_tail = m_threads_push_head;
165 return m_methods_push_head->next_runnable() ==
SC_NO_METHODS &&
179 return m_methods_push_head && m_threads_push_head;
193 DEBUG_MSG(DEBUG_NAME,method_h,
"pushing back method");
195 m_methods_push_tail->set_next_runnable(method_h);
196 m_methods_push_tail = method_h;
210 DEBUG_MSG(DEBUG_NAME,thread_h,
"pushing back thread");
212 m_threads_push_tail->set_next_runnable(thread_h);
213 m_threads_push_tail = thread_h;
228 DEBUG_MSG(DEBUG_NAME,method_h,
"pushing front method");
229 method_h->set_next_runnable(m_methods_push_head->next_runnable());
230 if ( m_methods_push_tail == m_methods_push_head )
232 m_methods_push_tail->set_next_runnable(method_h);
233 m_methods_push_tail = method_h;
237 m_methods_push_head->set_next_runnable(method_h);
253 DEBUG_MSG(DEBUG_NAME,thread_h,
"pushing front thread");
254 thread_h->set_next_runnable(m_threads_push_head->next_runnable());
255 if ( m_threads_push_tail == m_threads_push_head )
257 m_threads_push_tail->set_next_runnable(thread_h);
258 m_threads_push_tail = thread_h;
262 m_threads_push_head->set_next_runnable(thread_h);
276 result_p = m_methods_pop;
279 m_methods_pop = result_p->next_runnable();
280 result_p->set_next_runnable(0);
286 DEBUG_MSG(DEBUG_NAME,result_p,
"popping method");
301 result_p = m_threads_pop;
304 m_threads_pop = result_p->next_runnable();
305 result_p->set_next_runnable(0);
311 DEBUG_MSG(DEBUG_NAME,result_p,
"popping thread for execution");
335 prior_p = m_methods_push_head;
337 now_p = now_p->next_runnable() )
339 if ( remove_p == now_p )
341 prior_p->set_next_runnable( now_p->next_runnable() );
342 if (now_p == m_methods_push_tail) {
343 m_methods_push_tail = prior_p;
345 now_p->set_next_runnable(0);
346 DEBUG_MSG(DEBUG_NAME,now_p,
"removing method from push queue");
356 now_p = now_p->next_runnable() )
358 if ( remove_p == now_p )
361 prior_p->set_next_runnable( now_p->next_runnable() );
363 m_methods_pop = now_p->next_runnable();
364 now_p->set_next_runnable(0);
365 DEBUG_MSG(DEBUG_NAME,now_p,
"removing method from pop queue");
392 prior_p = m_threads_push_head;
394 now_p = now_p->next_runnable() )
396 if ( remove_p == now_p )
398 prior_p->set_next_runnable( now_p->next_runnable() );
399 if (now_p == m_threads_push_tail) {
400 m_threads_push_tail = prior_p;
402 now_p->set_next_runnable(0);
403 DEBUG_MSG(DEBUG_NAME,now_p,
"removing thread from push queue");
413 now_p = now_p->next_runnable() )
415 if ( remove_p == now_p )
418 prior_p->set_next_runnable( now_p->next_runnable() );
420 m_threads_pop = now_p->next_runnable();
421 now_p->set_next_runnable(0);
422 DEBUG_MSG(DEBUG_NAME,now_p,
"removing thread from pop queue");
435 m_methods_push_head(0), m_methods_push_tail(0), m_methods_pop(
SC_NO_METHODS),
436 m_threads_push_head(0), m_threads_push_tail(0), m_threads_pop(
SC_NO_THREADS)
446 delete m_methods_push_head;
447 delete m_threads_push_head;
461 m_methods_pop = m_methods_push_head->next_runnable();
463 m_methods_push_tail = m_methods_push_head;
478 m_threads_pop = m_threads_push_head->next_runnable();
480 m_threads_push_tail = m_threads_push_head;
570 #endif // SC_RUNNABLE_INT_H
void push_front_thread(sc_thread_handle)
#define DEBUG_MSG(NAME, P, MSG)
void(sc_process_host::* SC_ENTRY_FUNC)()
void push_front_method(sc_method_handle)
class sc_thread_process * sc_thread_handle
void push_back_method(sc_method_handle)
void execute_method_next(sc_method_handle)
void execute_thread_next(sc_thread_handle)
void remove_method(sc_method_handle)
void push_back_thread(sc_thread_handle)
bool is_initialized() const
void remove_thread(sc_thread_handle)
sc_method_handle pop_method()
class sc_method_process * sc_method_handle
sc_thread_handle pop_thread()