You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

48 lines
1.4 KiB

  1. /datum/BSQL_Operation
  2. var/datum/BSQL_Connection/connection
  3. var/id
  4. BSQL_PROTECT_DATUM(/datum/BSQL_Operation)
  5. /datum/BSQL_Operation/New(datum/BSQL_Connection/connection, id)
  6. src.connection = connection
  7. src.id = id
  8. BSQL_DEL_PROC(/datum/BSQL_Operation)
  9. var/error
  10. if(!BSQL_IS_DELETED(connection))
  11. error = world._BSQL_Internal_Call("ReleaseOperation", connection.id, id)
  12. . = ..()
  13. if(error)
  14. BSQL_ERROR(error)
  15. /datum/BSQL_Operation/IsComplete()
  16. if(BSQL_IS_DELETED(connection))
  17. return TRUE
  18. var/result = world._BSQL_Internal_Call("OpComplete", connection.id, id)
  19. if(!result)
  20. BSQL_ERROR("Error fetching operation [id] for connection [connection.id]!")
  21. return
  22. return result == "DONE"
  23. /datum/BSQL_Operation/GetError()
  24. if(BSQL_IS_DELETED(connection))
  25. return "Connection deleted!"
  26. return world._BSQL_Internal_Call("GetError", connection.id, id)
  27. /datum/BSQL_Operation/GetErrorCode()
  28. if(BSQL_IS_DELETED(connection))
  29. return -2
  30. return text2num(world._BSQL_Internal_Call("GetErrorCode", connection.id, id))
  31. /datum/BSQL_Operation/WaitForCompletion()
  32. if(BSQL_IS_DELETED(connection))
  33. return
  34. var/error = world._BSQL_Internal_Call("BlockOnOperation", connection.id, id)
  35. if(error)
  36. if(error == "Operation timed out!") //match this with the implementation
  37. return FALSE
  38. BSQL_ERROR("Error waiting for operation [id] for connection [connection.id]! [error]")
  39. return
  40. return TRUE