コード例 #1
0
ファイル: test_10963.cpp プロジェクト: ForDrink/boost-ios
int main()
{
#if ! defined  BOOST_NO_CXX11_DECLTYPE && ! defined  BOOST_NO_CXX11_AUTO_DECLARATIONS
    boost::promise<void> test_promise;
    boost::future<void> test_future(test_promise.get_future());
    auto f1 = test_future.then(TestCallback());
    BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
    auto f2 = f1.then(TestCallback());
    BOOST_STATIC_ASSERT(std::is_same<decltype(f2), boost::future<boost::future<void> > >::value);
#endif
    return 0;
}
コード例 #2
0
ファイル: clientMain.c プロジェクト: H-H-bin/legato-af
void test3(void)
{
    banner("Test 3");

    // Test what happens if an event is triggered, then the handler is removed.  The registered
    // handler should not be called, even if there is a pending event, because the handler has
    // been removed.
    TestAHandlerRef_t handlerRef = AddTestAHandler(NewHandleTestA, NULL);
    LE_PRINT_VALUE("%p", handlerRef);

    LE_DEBUG("Triggering New TestA\n");
    TriggerTestA();

    RemoveTestAHandler(handlerRef);


    // Test function callback parameters.
    int result;

    // This is not used in the test; this parameter was added to test a code generation bug fix.
    uint8_t dataArray[] = { 1, 2 };

    result = TestCallback(10, dataArray, 2, CallbackTestHandler, NULL);
    LE_PRINT_VALUE("%d", result);

    LE_DEBUG("Triggering CallbackTest");
    TriggerCallbackTest(100);

    // Need to allow the event loop to process the trigger.
    // The rest of the test will be continued in the handler.
}
コード例 #3
0
ファイル: server.c プロジェクト: ekral85/legato-af
static void Handle_TestCallback
(
    le_msg_MessageRef_t _msgRef

)
{
    // Get the message buffer pointer
    uint8_t* _msgBufPtr = ((_Message_t*)le_msg_GetPayloadPtr(_msgRef))->buffer;

    // Needed if we are returning a result or output values
    uint8_t* _msgBufStartPtr = _msgBufPtr;

    // Unpack the input parameters from the message
    uint32_t someParm;
    _msgBufPtr = UnpackData( _msgBufPtr, &someParm, sizeof(uint32_t) );

    size_t dataArrayNumElements;
    _msgBufPtr = UnpackData( _msgBufPtr, &dataArrayNumElements, sizeof(size_t) );

    uint8_t dataArray[dataArrayNumElements];
    _msgBufPtr = UnpackData( _msgBufPtr, dataArray, dataArrayNumElements*sizeof(uint8_t) );



    void* contextPtr;
    _msgBufPtr = UnpackData( _msgBufPtr, &contextPtr, sizeof(void*) );

    // Create a new server data object and fill it in
    _ServerData_t* serverDataPtr = le_mem_ForceAlloc(_ServerDataPool);
    serverDataPtr->clientSessionRef = le_msg_GetSession(_msgRef);
    serverDataPtr->contextPtr = contextPtr;
    serverDataPtr->handlerRef = NULL;
    serverDataPtr->removeHandlerFunc = NULL;
    contextPtr = serverDataPtr;

    // Define storage for output parameters


    // Call the function
    int32_t _result;
    _result = TestCallback ( someParm, dataArray, dataArrayNumElements, AsyncResponse_TestCallback, contextPtr );



    // Re-use the message buffer for the response
    _msgBufPtr = _msgBufStartPtr;

    // Pack the result first
    _msgBufPtr = PackData( _msgBufPtr, &_result, sizeof(_result) );

    // Pack any "out" parameters


    // Return the response
    LE_DEBUG("Sending response to client session %p : %ti bytes sent",
             le_msg_GetSession(_msgRef),
             _msgBufPtr-_msgBufStartPtr);
    le_msg_Respond(_msgRef);
}
コード例 #4
0
ファイル: yexception_ut.cpp プロジェクト: Mirocow/balancer
 //! tests propagation of an exception through C code
 //! @note on some platforms, for example GCC on 32-bit Linux without -fexceptions option,
 //!       throwing an exception from a C++ callback through C code aborts program
 inline void TestMixedCode() {
     const int N = 26082009;
     try {
         TestCallback(&CallbackFun, N);
         UNIT_ASSERT(false);
     } catch (int i) {
         UNIT_ASSERT_VALUES_EQUAL(i, N);
     }
 }
コード例 #5
0
ファイル: client.cpp プロジェクト: akostrikov/ATCD
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
    try
    {
        CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

        CORBA::Object_var poa_object =
            orb->resolve_initial_references("RootPOA");

        PortableServer::POA_var root_poa =
            PortableServer::POA::_narrow (poa_object.in ());

        if (CORBA::is_nil (root_poa.in ()))
            ACE_ERROR_RETURN ((LM_ERROR,
                               " (%P|%t) Panic: nil RootPOA\n"),
                              1);

        PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();

        if (parse_args (argc, argv) != 0)
            return 1;

        // Create client callback CORBA object

        TestCallback *test_impl = 0;
        ACE_NEW_RETURN (test_impl,
                        TestCallback (orb.in()),
                        1);
        PortableServer::ServantBase_var owner_transfer(test_impl);

        PortableServer::ObjectId_var id =
            root_poa->activate_object (test_impl);

        CORBA::Object_var object = root_poa->id_to_reference (id.in ());

        Test::TestCallback_var client = Test::TestCallback::_narrow (object.in ());

        poa_manager->activate ();

        // Get server CORBA object and call it

        CORBA::Object_var tmp = orb->string_to_object(ior);

        Test::TestServer_var server = Test::TestServer::_narrow(tmp.in ());

        if (CORBA::is_nil (server.in ()))
        {
            ACE_ERROR_RETURN ((LM_DEBUG,
                               "Nil Test::TestServer reference <%s>\n",
                               ior),
                              1);
        }

        ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - calling server\n"));
        server->pass_callback (client.in());

        ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - call failed to block\n"));
    }
    catch (const CORBA::Exception& ex)
    {
        ex._tao_print_exception ("Exception caught:");
        return 1;
    }

    ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - not stopped by server\n"));
    return 1;
}