コード例 #1
0
ファイル: receiver.hpp プロジェクト: eile/hpx
 bool check_tag_sent()
 {
     if(request_ready())
     {
         return start_send();
     }
     return next(&receiver::check_tag_sent);
 }
コード例 #2
0
ファイル: receiver.hpp プロジェクト: eile/hpx
        bool check_chunks_recvd()
        {
            if(request_ready())
            {
                return recv_chunks();
            }

            return next(&receiver::check_chunks_recvd);
        }
コード例 #3
0
ファイル: receiver.hpp プロジェクト: eile/hpx
        bool check_transmission_chunks_recvd()
        {
            if(request_ready())
            {
                return recv_data();
            }

            return next(&receiver::check_transmission_chunks_recvd);
        }
コード例 #4
0
ファイル: receiver.hpp プロジェクト: eile/hpx
        bool check_ack_sent()
        {
            if(request_ready())
            {
                next(0);
                return true;
            }

            return next(&receiver::check_ack_sent);
        }
コード例 #5
0
ファイル: baked_lightmap.cpp プロジェクト: DSeanLaw/godot
void BakedLightmap::_notification(int p_what) {
	if (p_what == NOTIFICATION_READY) {

		if (light_data.is_valid()) {
			_assign_lightmaps();
		}
		request_ready(); //will need ready again if re-enters tree
	}

	if (p_what == NOTIFICATION_EXIT_TREE) {

		if (light_data.is_valid()) {
			_clear_lightmaps();
		}
	}
}
コード例 #6
0
ファイル: main.cpp プロジェクト: mstump/libuv-test
int
main()
{
    {
        // create the context
        context_t c;

        std::cout << "//////////////////////////////////////////////////////////////////////" << std::endl;
        std::cout << "//" << std::endl;
        std::cout << "//               STARTING CALLBACKS DEMO" << std::endl;
        std::cout << "//" << std::endl;
        std::cout << "//////////////////////////////////////////////////////////////////////" << std::endl;
        std::cout << std::endl;

        // queue up a bunch of requests
        for (int i = COUNT.load(std::memory_order_relaxed); i > 0; i--) {
            c.create_request(i, my_callback);
        }

        // wait until we've received callbacks from all of the requests
        for (;;) {
            int count = COUNT.load(std::memory_order_consume);
            if (! count > 0) {
                break;
            }
            std::this_thread::sleep_for(std::chrono::seconds(1));
        }

        std::cout << std::endl << std::endl << std::endl;
        std::cout << "//////////////////////////////////////////////////////////////////////" << std::endl;
        std::cout << "//" << std::endl;
        std::cout << "//               STARTING FUTURE/PROMISE DEMO" << std::endl;
        std::cout << "//" << std::endl;
        std::cout << "//////////////////////////////////////////////////////////////////////" << std::endl;
        std::cout << std::endl;

        for (int i = 0; i < 10; ++i) {
            context_t::caller_request_t* request = c.create_request(i);
            request->wait();
            std::cout << "future/promise returned from the wait condition";
            std::cout << ", future/promise is ready: " << (request->ready() ? "TRUE" : "FALSE");
            std::cout << ", future/promise result is: " << request->result << std::endl;

            // when using the future/promise it's the job of the caller to delete
            // the request freeing up all memory allocated for that request.
            // this is done because the library doesn't know how long the caller
            // will need to keep the request around
            delete request;
        }
    }

    {
        std::cout << std::endl << std::endl << std::endl;
        std::cout << "//////////////////////////////////////////////////////////////////////" << std::endl;
        std::cout << "//" << std::endl;
        std::cout << "//            STARTING OPAQUE STRUCTURES/POINTERS DEMO" << std::endl;
        std::cout << "//" << std::endl;
        std::cout << "//////////////////////////////////////////////////////////////////////" << std::endl;
        std::cout << std::endl;

        void* c = new_context();

        for (int i = 0; i < 10; ++i) {
            void* request = context_create_request(c, i);
            request_wait(request);
            std::cout << "future/promise returned from the wait condition";
            std::cout << ", future/promise is ready: " << (request_ready(request) ? "TRUE" : "FALSE");
            std::cout << ", future/promise result is: " << request_result(request) << std::endl;

            // when using the future/promise it's the job of the caller to delete
            // the request freeing up all memory allocated for that request.
            // this is done because the library doesn't know how long the caller
            // will need to keep the request around
            free_request(request);
        }
        free_context(c);
    }
}