Method: Mosquitto::Client#loop_start
- Defined in:
- ext/mosquitto/client.c
#loop_start ⇒ Boolean
This is part of the threaded client interface. Call this once to start a new thread to process network traffic. This provides an alternative to repeatedly calling Mosquitto::Client#loop yourself.
1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 |
# File 'ext/mosquitto/client.c', line 1546 static VALUE rb_mosquitto_client_loop_start(VALUE obj) { int ret; struct timeval time; MosquittoGetClient(obj); /* Let's not spawn duplicate threaded loops */ if (!NIL_P(client->callback_thread)) return Qtrue; ret = (int)rb_thread_call_without_gvl(rb_mosquitto_client_loop_start_nogvl, (void *)client->mosq, RUBY_UBF_IO, 0); switch (ret) { case MOSQ_ERR_INVAL: MosquittoError("invalid input params"); break; case MOSQ_ERR_NOT_SUPPORTED : MosquittoError("thread support is not available"); break; default: pthread_mutex_init(&client->callback_mutex, NULL); pthread_cond_init(&client->callback_cond, NULL); client->callback_thread = rb_thread_create(rb_mosquitto_callback_thread, client); /* Allow the callback thread some startup time */ time.tv_sec = 0; time.tv_usec = 100 * 1000; /* 0.1 sec */ rb_thread_wait_for(time); return Qtrue; } } |