sc_spawn.hh (13260:4d18f1d20093) | sc_spawn.hh (13267:7997f7b8bede) |
---|---|
1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright --- 16 unchanged lines hidden (view full) --- 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 * Authors: Gabe Black 28 */ 29 30#ifndef __SYSTEMC_EXT_CORE_SC_SPAWN_HH__ 31#define __SYSTEMC_EXT_CORE_SC_SPAWN_HH__ 32 | 1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright --- 16 unchanged lines hidden (view full) --- 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 * Authors: Gabe Black 28 */ 29 30#ifndef __SYSTEMC_EXT_CORE_SC_SPAWN_HH__ 31#define __SYSTEMC_EXT_CORE_SC_SPAWN_HH__ 32 |
33#include <functional> |
|
33#include <vector> 34 35#include "sc_join.hh" 36#include "sc_process_handle.hh" 37 38namespace sc_core 39{ 40 --- 127 unchanged lines hidden (view full) --- 168 const sc_spawn_options *opt_p=nullptr) 169{ 170 auto func = new ::sc_gem5::ProcessObjRetFuncWrapper< 171 T, typename T::result_type>(object, r_p); 172 ::sc_gem5::Process *p = spawnWork(func, name_p, opt_p); 173 return sc_process_handle() = p; 174} 175 | 34#include <vector> 35 36#include "sc_join.hh" 37#include "sc_process_handle.hh" 38 39namespace sc_core 40{ 41 --- 127 unchanged lines hidden (view full) --- 169 const sc_spawn_options *opt_p=nullptr) 170{ 171 auto func = new ::sc_gem5::ProcessObjRetFuncWrapper< 172 T, typename T::result_type>(object, r_p); 173 ::sc_gem5::Process *p = spawnWork(func, name_p, opt_p); 174 return sc_process_handle() = p; 175} 176 |
176#define sc_bind boost::bind 177#define sc_ref(r) boost::ref(r) 178#define sc_cref(r) boost::cref(r) 179 | |
180#define SC_FORK \ 181{ \ 182 ::sc_core::sc_process_handle forkees[] = { 183 184#define SC_JOIN \ 185 }; \ 186 ::sc_core::sc_join join; \ 187 for (int i = 0; i < sizeof(forkees) / sizeof(forkees[0]); i++) \ --- 5 unchanged lines hidden (view full) --- 193#define SC_CJOIN \ 194 }; \ 195 ::sc_core::sc_join join; \ 196 for (int i = 0; i < sizeof(forkees) / sizeof(forkees[0]); i++) \ 197 join.add_process(forkees[i]); \ 198 join.wait_clocked(); \ 199} 200 | 177#define SC_FORK \ 178{ \ 179 ::sc_core::sc_process_handle forkees[] = { 180 181#define SC_JOIN \ 182 }; \ 183 ::sc_core::sc_join join; \ 184 for (int i = 0; i < sizeof(forkees) / sizeof(forkees[0]); i++) \ --- 5 unchanged lines hidden (view full) --- 190#define SC_CJOIN \ 191 }; \ 192 ::sc_core::sc_join join; \ 193 for (int i = 0; i < sizeof(forkees) / sizeof(forkees[0]); i++) \ 194 join.add_process(forkees[i]); \ 195 join.wait_clocked(); \ 196} 197 |
198// This avoids boost introduces a dependency on c++11. If that's a problem, 199// we could imitate Accellera and pick which one to use on the fly. |
|
201 | 200 |
201template <typename F, typename... Args> 202auto sc_bind(F &&f, Args && ...args) -> 203 decltype(std::bind(std::forward<F>(f), std::forward<Args>(args)...)) 204{ 205 return std::bind(std::forward<F>(f), std::forward<Args>(args)...); 206} 207 208template <typename T> 209auto sc_ref(T &&v) -> decltype(std::ref(std::forward<T>(v))) 210{ 211 return std::ref(std::forward<T>(v)); 212} 213 214template <typename T> 215auto sc_cref(T &&v) -> decltype(std::cref(std::forward<T>(v))) 216{ 217 return std::cref(std::forward<T>(v)); 218} 219 |
|
202} // namespace sc_core 203 | 220} // namespace sc_core 221 |
222using sc_core::sc_bind; 223using sc_core::sc_ref; 224using sc_core::sc_cref; 225 |
|
204namespace sc_unnamed 205{ 206 | 226namespace sc_unnamed 227{ 228 |
207typedef int ImplementationDefined; 208extern ImplementationDefined _1; 209extern ImplementationDefined _2; 210extern ImplementationDefined _3; 211extern ImplementationDefined _4; 212extern ImplementationDefined _5; 213extern ImplementationDefined _6; 214extern ImplementationDefined _7; 215extern ImplementationDefined _8; 216extern ImplementationDefined _9; | 229using namespace std::placeholders; |
217 218} // namespace sc_unnamed 219 220#endif //__SYSTEMC_EXT_CORE_SC_SPAWN_HH__ | 230 231} // namespace sc_unnamed 232 233#endif //__SYSTEMC_EXT_CORE_SC_SPAWN_HH__ |