Lines Matching refs:t
104 func (t *tracerImpl) startBuffer() {
105 t.w = nopCloser{&t.buf}
106 fmt.Fprintln(t.w, "[")
108 t.defineThread(MainThread, "main")
111 func (t *tracerImpl) close() {
112 if t.file != nil {
113 fmt.Fprintln(t.w, "]")
115 if err := t.w.Close(); err != nil {
116 t.log.Println("Error closing trace writer:", err)
119 if err := t.file.Close(); err != nil {
120 t.log.Println("Error closing trace file:", err)
122 t.file = nil
123 t.startBuffer()
128 func (t *tracerImpl) SetOutput(filename string) {
129 t.lock.Lock()
130 defer t.lock.Unlock()
132 t.close()
141 t.log.Println("Failed to create trace file:", err)
146 t.file = f
147 t.w = gzip.NewWriter(f)
150 if _, err := io.Copy(t.w, &t.buf); err != nil {
151 t.log.Println("Failed to write trace buffer to file:", err)
153 t.buf = bytes.Buffer{}
158 func (t *tracerImpl) Close() {
159 t.lock.Lock()
160 defer t.lock.Unlock()
162 t.close()
165 func (t *tracerImpl) writeEvent(event *viewerEvent) {
166 t.lock.Lock()
167 defer t.lock.Unlock()
169 t.writeEventLocked(event)
172 func (t *tracerImpl) writeEventLocked(event *viewerEvent) {
175 t.log.Println("Failed to marshal event:", err)
176 t.log.Verbosef("Event: %#v", event)
180 if !t.firstEvent {
181 fmt.Fprintln(t.w, ",")
183 t.firstEvent = false
186 if _, err = t.w.Write(bytes); err != nil {
187 t.log.Println("Trace write error:", err)
191 func (t *tracerImpl) defineThread(thread Thread, name string) {
192 t.writeEventLocked(&viewerEvent{
205 func (t *tracerImpl) NewThread(name string) Thread {
206 t.lock.Lock()
207 defer t.lock.Unlock()
209 ret := Thread(t.nextTid)
210 t.nextTid += 1
212 t.defineThread(ret, name)
218 func (t *tracerImpl) Begin(name string, thread Thread) {
219 t.writeEvent(&viewerEvent{
229 func (t *tracerImpl) End(thread Thread) {
230 t.writeEvent(&viewerEvent{
240 func (t *tracerImpl) Complete(name string, thread Thread, begin, end uint64) {
241 t.writeEvent(&viewerEvent{