zactor_t * zactor_new (zactor_fn *actor, void *args) { zactor_t *self = (zactor_t *) zmalloc (sizeof (zactor_t)); if (!self) return NULL; self->tag = ZACTOR_TAG; shim_t *shim = (shim_t *) zmalloc (sizeof (shim_t)); if (!shim) { zactor_destroy (&self); return NULL; } shim->pipe = zsys_create_pipe (&self->pipe); shim->handler = actor; shim->args = args; #if defined (__UNIX__) pthread_t thread; pthread_create (&thread, NULL, s_thread_shim, shim); pthread_detach (thread); #elif defined (__WINDOWS__) HANDLE handle = (HANDLE) _beginthreadex ( NULL, // Handle is private to this process 0, // Use a default stack size for new thread &s_thread_shim, // Start real thread function via this shim shim, // Which gets arguments shim CREATE_SUSPENDED, // Set thread priority before starting it NULL); // We don't use the thread ID assert (handle); // Set child thread priority to same as current int priority = GetThreadPriority (GetCurrentThread ()); SetThreadPriority (handle, priority); // Start thread & release resources ResumeThread (handle); CloseHandle (handle); #endif // Mandatory handshake for new actor so that constructor returns only // when actor has also initialized. This eliminates timing issues at // application start up. zsock_wait (self->pipe); return self; }
static stream_t * s_stream_new (client_t *client, const char *name) { stream_t *self = (stream_t *) zmalloc (sizeof (stream_t)); if (self) { zsock_t *backend; self->name = strdup (name); if (self->name) self->msgpipe = zsys_create_pipe (&backend); if (self->msgpipe) { engine_handle_socket (client->server, self->msgpipe, s_forward_stream_traffic); self->actor = zactor_new (mlm_stream_simple, backend); } if (!self->actor) s_stream_destroy (&self); } return self; }
zyre_t * zyre_new (const char *name) { zyre_t *self = (zyre_t *) zmalloc (sizeof (zyre_t)); assert (self); // Create front-to-back pipe pair for data traffic zsock_t *outbox; self->inbox = zsys_create_pipe (&outbox); // Start node engine and wait for it to be ready self->actor = zactor_new (zyre_node_actor, outbox); assert (self->actor); // Send name, if any, to node ending if (name) zstr_sendx (self->actor, "SET NAME", name, NULL); return self; }
JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsys__1_1createPipe (JNIEnv *env, jclass c, jlong backend_p) { jlong create_pipe_ = (jlong) (intptr_t) zsys_create_pipe ((zsock_t **) (intptr_t) &backend_p); return create_pipe_; }
/// // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. QmlZsock *QmlZsysAttached::createPipe (QmlZsock *backendP) { QmlZsock *retQ_ = new QmlZsock (); retQ_->self = zsys_create_pipe (&backendP->self); return retQ_; };
/// // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. QZsock * QZsys::createPipe (QZsock *backendP) { QZsock *rv = new QZsock (zsys_create_pipe (&backendP->self)); return rv; }