PageRenderTime 25ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/wheels/vendor/memcached/com/FutureTask.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 98 lines | 88 code | 8 blank | 2 comment | 12 complexity | 8b409a8e8ee3c2aa0805b94cd48bb08f MD5 | raw file
Possible License(s): Apache-2.0, CPL-1.0
  1. <cfcomponent extends="_base" output="false">
  2. <!----------
  3. Cancel() - returns a boolean - allows you to cancel the operation
  4. get( int, variables.timeunit ) - returns object - when an interger is sent in, you can
  5. get the result in that amount of time.
  6. get() - returns an object - get the result when it is available.
  7. isCancelled() - returns boolean - lets you know if the operation was cancelled
  8. isDone() - returns boolean -
  9. ---------->
  10. <cfset variables._futureTask = "">
  11. <cfset variables.inited = false>
  12. <cffunction name="init" access="public" output="false" returntype="Any" hint="init func to set the futureTask">
  13. <cfargument name="myFutureTask" required="true" type="any"
  14. hint="this must be a future Task returned by the java memcached client otherwise, this will fail.">
  15. <cfset variables._futureTask = arguments.myFutureTask>
  16. <cfif isObject(arguments.myFutureTask)>
  17. <cfset variables.inited = true>
  18. </cfif>
  19. <cfset super.init()>
  20. <cfreturn this>
  21. </cffunction>
  22. <cffunction name="isDone" access="public" output="false" returntype="boolean"
  23. hint="returns true when the operation has finished. otherwise it returns false">
  24. <cfscript>
  25. var ret = false;
  26. if (variables.inited ) {
  27. ret = variables._futureTask.isDone();
  28. }
  29. if (not isDefined("ret")) {
  30. ret = false;
  31. }
  32. </cfscript>
  33. <cfreturn ret>
  34. </cffunction>
  35. <Cffunction name="isCancelled" access="public" output="false" returntype="boolean"
  36. hint="Returns true if the fetch has been cancelled. false otherwise">
  37. <cfscript>
  38. var ret = false;
  39. if (variables.inited ) {
  40. ret = variables._futureTask.isCancelled();
  41. }
  42. if (not isDefined("ret")) {
  43. ret = false;
  44. }
  45. </cfscript>
  46. <cfreturn ret>
  47. </Cffunction>
  48. <cffunction name="cancel" access="public" output="false" returntype="boolean"
  49. hint="cancels the returning result.">
  50. <cfscript>
  51. var ret = false;
  52. if (variables.inited ) {
  53. ret = variables._futureTask.cancel();
  54. }
  55. if (not isDefined("ret")) {
  56. ret = false;
  57. }
  58. </cfscript>
  59. <cfreturn ret>
  60. </cffunction>
  61. <cffunction name="get" access="public" output="false" returntype="any"
  62. hint="Gets the result, when available. if the result is not available, it will return an empty string">
  63. <cfargument name="timeout" type="numeric" required="false" default="#variables.defaultRequestTimeout#"
  64. hint="the number of milliseconds to wait until for the response.
  65. a timeout setting of 0 will wait forever for a response from the server"/>
  66. <cfargument name="timeoutUnit" type="string" required="false" default="#variables.defaultTimeoutUnit#"
  67. hint="The timeout unit to use for the timeout"/>
  68. <cfscript>
  69. var ret = "";
  70. // gotta go through all this to catch the nulls.
  71. try {
  72. if ( arguments.timeout neq 0 and variables.inited) {
  73. ret = variables._futureTask.Get(arguments.timeout, getTimeUnitType(arguments.timeoutUnit));
  74. } else if (variables.inited ) {
  75. ret = variables._futureTask.Get();
  76. }
  77. // additional processing might be required.
  78. if (not isdefined("ret")) {
  79. ret = "";
  80. } else {
  81. ret = deserialize(ret);
  82. }
  83. } catch(Any e) {
  84. ret = "";
  85. cancel();
  86. }
  87. </cfscript>
  88. <cfreturn ret/>
  89. </cffunction>
  90. </cfcomponent>