src/Pure/Tools/build_process.scala
changeset 78546 e3ae7293c5df
parent 78545 5f4ca329fde4
child 78552 384adc74e27d
equal deleted inserted replaced
78545:5f4ca329fde4 78546:e3ae7293c5df
   763 
   763 
   764     val build_uuid_tables =
   764     val build_uuid_tables =
   765       tables.filter(table =>
   765       tables.filter(table =>
   766         table.columns.exists(column => column.name == Generic.build_uuid.name))
   766         table.columns.exists(column => column.name == Generic.build_uuid.name))
   767 
   767 
   768     def pull_database(
   768     def pull_database(db: SQL.Database, worker_uuid: String, state: State): State = {
   769       db: SQL.Database,
       
   770       worker_uuid: String,
       
   771       hostname: String,
       
   772       state: State
       
   773     ): State = {
       
   774       val serial_db = read_serial(db)
   769       val serial_db = read_serial(db)
   775       if (serial_db == state.serial) state
   770       if (serial_db == state.serial) state
   776       else {
   771       else {
   777         val serial = serial_db max state.serial
   772         val serial = serial_db max state.serial
   778         stamp_worker(db, worker_uuid, serial)
   773         stamp_worker(db, worker_uuid, serial)
   785         state.copy(serial = serial, sessions = sessions, pending = pending,
   780         state.copy(serial = serial, sessions = sessions, pending = pending,
   786           running = running, results = results)
   781           running = running, results = results)
   787       }
   782       }
   788     }
   783     }
   789 
   784 
   790     def update_database(
   785     def update_database(db: SQL.Database, worker_uuid: String, state: State): State = {
   791       db: SQL.Database,
       
   792       worker_uuid: String,
       
   793       build_uuid: String,
       
   794       hostname: String,
       
   795       state: State
       
   796     ): State = {
       
   797       val changed =
   786       val changed =
   798         List(
   787         List(
   799           update_sessions(db, state.sessions),
   788           update_sessions(db, state.sessions),
   800           update_pending(db, state.pending),
   789           update_pending(db, state.pending),
   801           update_running(db, state.running),
   790           update_running(db, state.running),
   929     synchronized {
   918     synchronized {
   930       _build_database match {
   919       _build_database match {
   931         case None => body
   920         case None => body
   932         case Some(db) =>
   921         case Some(db) =>
   933           Build_Process.private_data.transaction_lock(db, label = label) {
   922           Build_Process.private_data.transaction_lock(db, label = label) {
   934             _state = Build_Process.private_data.pull_database(db, worker_uuid, hostname, _state)
   923             _state = Build_Process.private_data.pull_database(db, worker_uuid, _state)
   935             val res = body
   924             val res = body
   936             _state =
   925             _state = Build_Process.private_data.update_database(db, worker_uuid, _state)
   937               Build_Process.private_data.update_database(db, worker_uuid, build_uuid, hostname, _state)
       
   938             res
   926             res
   939           }
   927           }
   940       }
   928       }
   941     }
   929     }
   942 
   930