예제 #1
0
            // put tuple into tuplespace
            // out function
            int write(const tuple_type& tp)
            {
                if(tp.empty())
                {
                    return -1;
                }

                {
                    boost::lock_guard<mutex_type> l(mtx_);

                    tuples_.insert(tp);
                }

                return 0;
            }
void print_tuple(const tuple_type& tuple)
{
    if(tuple.empty())
    {
        hpx::cout<<"()";
        return;
    }

    tuple_type::const_iterator it = tuple.begin();
    hpx::cout<<"("<<*it;
    for(++it; it != tuple.end(); ++it)
    {
        hpx::cout<<", "<<*it;
    }
    hpx::cout<<")";
}
예제 #3
0
            tuple_type match_and_erase(const tuple_type& tp)
            {
                tuple_type result;

                if(tp.empty())
                {
                    return take_random_tuple();
                    // return random results for an empty tuple
                }

                matched_indices_type matched_indices;

                matched_indices = find_matched_indices(tp);

                if(!matched_indices.empty())
                {
                    // return the tuple at the first index
                    result = take_tuple_at(*(matched_indices.begin()));
                }

                return result;
            }
예제 #4
0
            int insert(const tuple_type& tp)
            {
                if(tp.empty()) // empty tuple
                    return -1;

                // whether size(tp) > size(tuple_fields_)
                while(tp.size() > tuple_fields_.size())
                {
                    tuple_field_container tmp;
                    tuple_fields_.push_back(tmp);
                }

                tuple_type::const_iterator it;
                unsigned int pos;
                for(it = tp.begin(), pos = 0; it != tp.end(); ++it, ++pos)
                {
                    tuple_fields_[pos].insert(index_, *it); // insert field
                }

                ++index_; // step up the index
                return 0;
            }