Team Fortress 2 Source Code as on 22/4/2020
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.

71 lines
2.0 KiB

  1. // Copyright 2013 the V8 project authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef V8_V8_PLATFORM_H_
  5. #define V8_V8_PLATFORM_H_
  6. namespace v8 {
  7. class Isolate;
  8. /**
  9. * A Task represents a unit of work.
  10. */
  11. class Task {
  12. public:
  13. virtual ~Task() {}
  14. virtual void Run() = 0;
  15. };
  16. /**
  17. * V8 Platform abstraction layer.
  18. *
  19. * The embedder has to provide an implementation of this interface before
  20. * initializing the rest of V8.
  21. */
  22. class Platform {
  23. public:
  24. /**
  25. * This enum is used to indicate whether a task is potentially long running,
  26. * or causes a long wait. The embedder might want to use this hint to decide
  27. * whether to execute the task on a dedicated thread.
  28. */
  29. enum ExpectedRuntime {
  30. kShortRunningTask,
  31. kLongRunningTask
  32. };
  33. virtual ~Platform() {}
  34. /**
  35. * Schedules a task to be invoked on a background thread. |expected_runtime|
  36. * indicates that the task will run a long time. The Platform implementation
  37. * takes ownership of |task|. There is no guarantee about order of execution
  38. * of tasks wrt order of scheduling, nor is there a guarantee about the
  39. * thread the task will be run on.
  40. */
  41. virtual void CallOnBackgroundThread(Task* task,
  42. ExpectedRuntime expected_runtime) = 0;
  43. /**
  44. * Schedules a task to be invoked on a foreground thread wrt a specific
  45. * |isolate|. Tasks posted for the same isolate should be execute in order of
  46. * scheduling. The definition of "foreground" is opaque to V8.
  47. */
  48. virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0;
  49. /**
  50. * Monotonically increasing time in seconds from an arbitrary fixed point in
  51. * the past. This function is expected to return at least
  52. * millisecond-precision values. For this reason,
  53. * it is recommended that the fixed point be no further in the past than
  54. * the epoch.
  55. **/
  56. virtual double MonotonicallyIncreasingTime() = 0;
  57. };
  58. } // namespace v8
  59. #endif // V8_V8_PLATFORM_H_