本文整理匯總了Golang中C.zmq_init函數的典型用法代碼示例。如果您正苦於以下問題:Golang zmq_init函數的具體用法?Golang zmq_init怎麽用?Golang zmq_init使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了zmq_init函數的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Init
//func GetSocketOption(socket *Socket,
func Init(io_threads int) (ZContext, os.Error) {
ptr := C.zmq_init(C.int(io_threads))
if ptr == nil {
return ZContext{nil}, error()
}
return ZContext{ptr}, nil
}
示例2: NewContextThreads
// Creates a new Context with the given number of dedicated IO threads.
func NewContextThreads(nthreads int) (ctx *Context, err error) {
ptr := C.zmq_init(C.int(nthreads))
if ptr == nil {
return nil, zmqerr()
}
return &Context{ptr}, nil
}
示例3: NewContext
// Create a new context.
// void *zmq_init (int io_threads);
func NewContext() (Context, error) {
// TODO Pass something useful here. Number of cores?
// C.NULL is correct but causes a runtime failure on darwin at present
if c := C.zmq_init(1); c != nil /*C.NULL*/ {
return &zmqContext{c}, nil
}
return nil, errno()
}
示例4: init
func init() {
var err error
nr_of_threads = 1
ctx, err = C.zmq_init(C.int(nr_of_threads))
if ctx == nil {
panic("Init of ZeroMQ context failed: " + errget(err).Error())
}
}
示例5: NewContext
// Create a new context.
// void *zmq_init (int io_threads);
func NewContext() (*Context, error) {
// TODO Pass something useful here. Number of cores?
c, err := C.zmq_init(1)
// C.NULL is correct but causes a runtime failure on darwin at present
if c != nil /*C.NULL*/ {
return &Context{c}, nil
}
return nil, casterr(err)
}
示例6: NewContext
// Creates a zmq context and returns it.
//
// Don't forget to set EnvGOMAXPROCS appropriately when working with libzmq
//
// Contexts are finalized by the GC unless they are manually destructed
// by calling Terminate() beforehand. Applications need to arrange
// that no socket is used or even closed after the owning context has
// been destructed. This requires to have at least one running go routine
// with a live referene to the context.
func (p libZmqProvider) NewContext(args InitArgs) (Context, os.Error) {
contextPtr := C.zmq_init(C.int(args.IoThreads))
if IsCNullPtr(uintptr(contextPtr)) {
return nil, p.GetError()
}
lzmqContext := lzmqContext(contextPtr)
return lzmqContext, nil
}
示例7: SetIoThreads
/*
This function specifies the size of the ØMQ thread pool to handle I/O operations.
If your application is using only the inproc transport for messaging you may set
this to zero, otherwise set it to at least one.
This function creates a new context without closing the old one. Use it before
creating any sockets.
Default value 1
*/
func SetIoThreads(n int) error {
if n != nr_of_threads {
c, err := C.zmq_init(C.int(n))
if c == nil {
return errget(err)
}
nr_of_threads = n
ctx = c
}
return nil
}
示例8: SetIoThreads
/*
This function specifies the size of the ØMQ thread pool to handle I/O operations.
If your application is using only the inproc transport for messaging you may set
this to zero, otherwise set it to at least one.
This function creates a new context without closing the old one. Use it before
creating any sockets.
Default value 1
*/
func SetIoThreads(n int) error {
if n != nr_of_threads {
c, err := C.zmq_init(C.int(n))
if c == nil {
return errget(err)
}
old = append(old, ctx) // keep a reference, to prevent garbage collection
ctx = c
nr_of_threads = n
}
return nil
}
示例9: NewContext
// Create a new context.
//
// The argument specifies the size of the ØMQ thread pool to handle I/O operations.
// If your application is using only the inproc transport for messaging you may set
// this to zero, otherwise set it to at least one.
func NewContext(nr_of_threads int) (ctx *Context, err error) {
ctx = &Context{}
c, e := C.zmq_init(C.int(nr_of_threads))
if c == nil {
err = errget(e)
ctx.err = err
} else {
ctx.ctx = c
ctx.opened = true
ctx.nr_of_threads = nr_of_threads
runtime.SetFinalizer(ctx, (*Context).Term)
}
return
}
示例10: SetIoThreads
/*
This function specifies the size of the ØMQ thread pool to handle I/O operations.
If your application is using only the inproc transport for messaging you may set
this to zero, otherwise set it to at least one.
This function creates a new default context without closing the old one.
Use it before creating any sockets.
Default value: 1
*/
func SetIoThreads(n int) error {
if n != nr_of_threads {
c, err := C.zmq_init(C.int(n))
if c == nil {
return errget(err)
}
old = append(old, defaultCtx) // keep a reference, to prevent garbage collection
defaultCtx = &Context{
ctx: c,
opened: true,
}
nr_of_threads = n
}
return nil
}
示例11: NewContext
// Create a new context.
func NewContext() (*Context, error) {
c := &Context{iothreads: 1}
c.init = func() {
c.mutex.Lock()
defer c.mutex.Unlock()
if c.c == nil && c.err == nil {
// C.NULL is correct but causes a runtime failure on darwin at present
if ptr, err := C.zmq_init(C.int(c.iothreads)); ptr != nil /*C.NULL*/ {
c.c = ptr
} else {
c.err = casterr(err)
}
}
}
return c, nil
}
示例12: init
func init() {
var err error
nr_of_threads = 1
defaultCtx = &Context{}
defaultCtx.ctx, err = C.zmq_init(C.int(nr_of_threads))
defaultCtx.opened = true
if defaultCtx.ctx == nil {
panic("Init of ZeroMQ context failed: " + errget(err).Error())
}
old = make([]*Context, 0)
major, minor, patch = Version()
if major != 2 {
panic("Using zmq2 with ZeroMQ major version " + fmt.Sprint(major))
}
if major != int(C.zmq2_major) || minor != int(C.zmq2_minor) || patch != int(C.zmq2_patch) {
panic(
fmt.Sprintf(
"zmq2 was installed with ZeroMQ version %d.%d.%d, but the application links with version %d.%d.%d",
int(C.zmq2_major), int(C.zmq2_minor), int(C.zmq2_patch),
major, minor, patch))
}
}
示例13: createZmqContext
func createZmqContext() unsafe.Pointer {
return C.zmq_init(1)
}