Exemplo n.º 1
0
    void output_stream::call_write_sync(detail::buffer in,
        threads::thread_id_type caller)
    {
        // Perform the IO operation.
        in.write(write_f, mtx_);

        // Wake up caller.
        threads::set_thread_state(caller, threads::pending);
    }
Exemplo n.º 2
0
        void output(boost::uint32_t locality_id, boost::uint64_t count,
            detail::buffer in, F const& write_f, Mutex& mtx)
        {
            typename Mutex::scoped_lock l(mtx);
            data_type& data = output_data_map_[locality_id];

            if (count == data.first)
            {
                // this is the next expected output line
                if (!in.empty())
                {
                    // output the line as requested
                    util::scoped_unlock<typename Mutex::scoped_lock> ul(l);
                    in.write(write_f, mtx);
                }
                ++data.first;

                // print all consecutive pending buffers
                output_data_type::iterator next = data.second.find(++count);
                while (next != data.second.end())
                {
                    buffer next_in = (*next).second;
                    if (!next_in.empty())
                    {
                        // output the next line
                        util::scoped_unlock<typename Mutex::scoped_lock> ul(l);
                        next_in.write(write_f, mtx);
                    }
                    data.second.erase(next);

                    // find next entry in map
                    ++data.first;
                    next = data.second.find(++count);
                }
            }
            else
            {
                HPX_ASSERT(count > data.first);
                data.second.insert(output_data_type::value_type(count, in));
            }
        }
Exemplo n.º 3
0
 void output_stream::call_write_async(detail::buffer in)
 { // {{{
     // Perform the IO operation.
     in.write(write_f, mtx_);
 } // }}}