예제 #1
0
파일: notmuch.go 프로젝트: notmuch/notmuch
/* Get the current thread from 'threads' as a notmuch_thread_t.
 *
 * Note: The returned thread belongs to 'threads' and has a lifetime
 * identical to it (and the query to which it belongs).
 *
 * See the documentation of notmuch_query_search_threads for example
 * code showing how to iterate over a notmuch_threads_t object.
 *
 * If an out-of-memory situation occurs, this function will return
 * NULL.
 */
func (self *Threads) Get() *Thread {
	if self.threads == nil {
		return nil
	}
	thread := C.notmuch_threads_get(self.threads)
	if thread == nil {
		return nil
	}
	return &Thread{thread}
}
예제 #2
0
파일: threads.go 프로젝트: gmuch/gmuch
func (ts *Threads) get() *Thread {
	cthread := C.notmuch_threads_get(ts.toC())
	checkOOM(unsafe.Pointer(cthread))
	thread := &Thread{
		cptr:   unsafe.Pointer(cthread),
		parent: (*cStruct)(ts),
	}
	setGcClose(thread)
	return thread
}
예제 #3
0
func (t *Threads) Get() *Thread {
	cthread := C.notmuch_threads_get(t.toC())
	// NOTE: we don't distinguish between OOM and calling Get when
	// !t.Valid(). As such, it's an error for the user to call Get
	// without first calling Valid.
	checkOOM(unsafe.Pointer(cthread))
	thread := &Thread{
		cptr:    cthread,
		threads: t,
	}
	runtime.SetFinalizer(thread, func(t *Thread) {
		C.notmuch_thread_destroy(t.toC())
	})
	return thread
}