In: |
p4table.rb
|
Parent: | Object |
Class for creating and formatting record id’s. Normally these are just of the form "<tablename>/<nnnnnn>"
seq | [RW] | |
table | [RW] |
Construct a new RecID for the given table name and sequence number
# File p4table.rb, line 230 230: def initialize( table, seq ) 231: @table = table 232: if ( seq.kind_of?( String ) ) 233: if ( seq =~ /^0*([1-9]\d+)$/ ) 234: @seq = $1.to_i 235: else 236: @seq = seq.to_i 237: end 238: else 239: @seq = seq 240: end 241: end
Instantiate a new P4RecID from the job name ( "<table>/<id>" ). Used to load existing records.
# File p4table.rb, line 222 222: def P4RecId.new_from_job( job ) 223: ( table, seq ) = job.split( "/" ) 224: P4RecId.new( P4Table.new( table ), seq ) 225: end
Get the next ID for the specified table using
Yes, this has a race condition, but there’s no atomic get and set operation for Perforce counters.
# File p4table.rb, line 210 210: def P4RecId.next( table ) 211: p4 = P4Global.tagged 212: val = p4.run_counter( table.name ).shift.to_i 213: val += 1 214: p4.run_counter( table.name, val ) 215: P4RecId.new( table, val ) 216: end