Skip to content

Commit

Permalink
Fixes for parallel classes
Browse files Browse the repository at this point in the history
  • Loading branch information
lwinkler committed Dec 16, 2018
1 parent c1cde47 commit d443b62
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
13 changes: 7 additions & 6 deletions class/broker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ void serialize_out(Archive & ar, std::tuple<typename pop_decay<Args>::type...> &
/// An object constructor for the broker
template<class ParClass> class broker_constructor_sync {
public:
broker_constructor_sync() {
}

broker_constructor_sync(ParClass* _p_obj) {
obj_ptr_.reset(_p_obj);
}

inline void construct(method_id_t _method_id, bufin& _ia, bufout& _oa) {
obj_ptr_.reset(constr_methods_.at(_method_id)(_ia, _oa));
}
Expand Down Expand Up @@ -124,12 +131,6 @@ template<class ParClass> class broker_constructor_sync {
/// An object constructor for the broker for async creation
template<class ParClass> class broker_constructor_async {
public:
broker_constructor_async() {
}

broker_constructor_async(ParClass* _p_obj) { // TODO: Remove
future_ = std::async(std::launch::async, [_p_obj](){return _p_obj;});
}

~broker_constructor_async() {
delete(future_.get());
Expand Down
5 changes: 3 additions & 2 deletions parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_full_name(node):
return ns + node.spelling

def find_parallel_classes(node, classnames):
""" Find all classes with annotation "pop_parallel"
""" Find all classes with annotation "pop_parallel:..."
"""

found = []
Expand Down Expand Up @@ -197,6 +197,7 @@ def get_class_construction_style(class_node):
"""
# print 'node %s %s %s [line=%s, col=%s]' % (class_node.get_definition(), class_node.spelling, class_node.kind, class_node.location.line, class_node.location.column)

# TODO: Replace with is_parallel
for c in class_node.get_children():
if c.kind == cindex.CursorKind.ANNOTATE_ATTR:
if c.spelling.startswith('pop_parallel:'):
Expand All @@ -222,7 +223,7 @@ def is_parallel(node):
"""
# describe_node(node)
for c in node.get_children():
if c.kind == cindex.CursorKind.ANNOTATE_ATTR and c.spelling == 'pop_parallel':
if c.kind == cindex.CursorKind.ANNOTATE_ATTR and c.spelling.startswith('pop_parallel:'):
return True
return False

Expand Down
5 changes: 3 additions & 2 deletions parser/parser_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ def write_forward_declaration(fout, full_name):
""" Write a forward declaration for the class """
namespaces = full_name.split('::')
for ns in namespaces[:-1]:
fout.write('namespace %s {' % ns)
fout.write('namespace %s {\n' % ns)
fout.write('class %s_iface;\n' % namespaces[-1])
for ns in namespaces[:-1]:
fout.write('}')
fout.write('}\n')

#--------------------------------------------------------------------------------
def write_head(fout, classname):
Expand Down
7 changes: 5 additions & 2 deletions util/local_broker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ namespace pop {
template<typename T> class local_broker final {
using Brok = pop::remote::broker<T, pop::remote::broker_constructor_sync<T>>;
public:
local_broker() : combox_(brok_), brok_(new T()) {
local_broker() :
brok_(new T()),
combox_(brok_)
{
}

inline void run() {
Expand All @@ -38,8 +41,8 @@ template<typename T> class local_broker final {
return combox_.contact();
}
private:
pop::broker_combox<Brok> combox_;
Brok brok_;
pop::broker_combox<Brok> combox_;
};
} // namespace pop

Expand Down

0 comments on commit d443b62

Please sign in to comment.