当前位置: 首页>>代码示例>>Golang>>正文


Golang C.zmq_init函数代码示例

本文整理汇总了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
}
开发者ID:badgerodon,项目名称:zmq,代码行数:8,代码来源:zmq.go

示例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
}
开发者ID:pakohan,项目名称:go-zmq,代码行数:8,代码来源:zmq.go

示例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()
}
开发者ID:psilva261,项目名称:gozmq,代码行数:10,代码来源:zmq.go

示例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())
	}
}
开发者ID:patrickToca,项目名称:zmq2,代码行数:8,代码来源:zmq2.go

示例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)
}
开发者ID:brunoqc,项目名称:gozmq,代码行数:11,代码来源:zmq.go

示例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
}
开发者ID:miffa,项目名称:gozero,代码行数:19,代码来源:zmq.go

示例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
}
开发者ID:patrickToca,项目名称:zmq2,代码行数:21,代码来源:zmq2.go

示例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
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:22,代码来源:zmq2.go

示例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
}
开发者ID:carosio,项目名称:chello,代码行数:19,代码来源:zmq2.go

示例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
}
开发者ID:carosio,项目名称:chello,代码行数:25,代码来源:zmq2.go

示例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
}
开发者ID:quenel,项目名称:gozmq,代码行数:17,代码来源:zmq.go

示例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))
	}
}
开发者ID:carosio,项目名称:chello,代码行数:22,代码来源:zmq2.go

示例13: createZmqContext

func createZmqContext() unsafe.Pointer {
	return C.zmq_init(1)
}
开发者ID:ajanicij,项目名称:gozmq,代码行数:3,代码来源:zmq_2_x.go


注:本文中的C.zmq_init函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。