Exemplo n.º 1
0
 EmptyObservable(Scheduler::shared scheduler) :
     ProducerBase([](Parent parent, std::shared_ptr < Observer < T >> observer, Disposable && cancel, typename ProducerBase::SetSink setSink) -> Disposable
     {
         auto sink = std::shared_ptr<_>(new _(parent, observer, std::move(cancel)));
         setSink(sink->GetDisposable());
         return sink->Run();
     }),
     scheduler(scheduler)
 {
     if (!scheduler) 
     { 
         this->scheduler = std::make_shared<CurrentThreadScheduler>(); 
     }
 }
Exemplo n.º 2
0
int main( int argc, char *argv[] )
{
    int l_nReturn;
    unsigned long l_threadHandle1;
    unsigned long l_threadHandle2;
    smtpSink_t * pSink = NULL;
    g_pClient = NULL;

    /*Initialize the global parameters*/
    g_szServer = argv[1];
    g_szDomain = argv[2];
    g_szSender = argv[3];
    g_szRecipient = argv[4];
    g_szData = argv[5];

    /*Initialize the response sink.*/
    l_nReturn = smtpSink_initialize( &pSink );

    if ( l_nReturn != NSMAIL_OK )
    {
        return l_nReturn;
    }

    /*Set the function pointers on the response sink.*/
    setSink( pSink );

    /*Initialize the client passing in the response sink.*/
    l_nReturn = smtp_initialize( &g_pClient, pSink );

    if ( l_nReturn != NSMAIL_OK )
    {
        return l_nReturn;
    }

/*Setup the mutex and the threads*/
#ifdef WIN32
    g_handle = CreateMutex( NULL, FALSE, NULL );

    l_threadHandle1 = _beginthread( SMTP_SendThread, 0, NULL );
    l_threadHandle2 = _beginthread( SMTP_CancelThread, 0, NULL );

    WaitForSingleObject( (HANDLE)l_threadHandle1, INFINITE );
    WaitForSingleObject( (HANDLE)l_threadHandle2, INFINITE );
#else
    pthread_mutex_init( &g_mp, NULL );
    pthread_create( &g_threadID1, NULL, SMTP_SendThread, NULL );
    pthread_create( &g_threadID2, NULL, SMTP_CancelThread, NULL );

    pthread_join( g_threadID1, NULL );
    pthread_join( g_threadID2, NULL );

    pthread_mutex_destroy( &g_mp );
#endif

    /*Free the client structure.*/
    smtp_free( &g_pClient );
    /*Free the sink structure.*/
    smtpSink_free( &pSink );

    return 0;
}
Exemplo n.º 3
0
void Log::restoreSink() {
	setSink(std::make_shared<DebugLogger>());
}