Line data Source code
1 : // Copyright 2012 The LevelDB-Go and Pebble Authors. All rights reserved. Use
2 : // of this source code is governed by a BSD-style license that can be found in
3 : // the LICENSE file.
4 :
5 : package pebble
6 :
7 : // JobID identifies a job (like a compaction). Job IDs are passed to event
8 : // listener notifications and act as a mechanism for tying together the events
9 : // and log messages for a single job such as a flush, compaction, or file
10 : // ingestion. Job IDs are not serialized to disk or used for correctness.
11 : type JobID int
12 :
13 : // newJobIDLocked returns a new JobID; DB.mu must be held.
14 2 : func (d *DB) newJobIDLocked() JobID {
15 2 : res := d.mu.nextJobID
16 2 : d.mu.nextJobID++
17 2 : return res
18 2 : }
19 :
20 2 : func (d *DB) newJobID() JobID {
21 2 : d.mu.Lock()
22 2 : defer d.mu.Unlock()
23 2 : return d.newJobIDLocked()
24 2 : }
|