Turn audio into a shareable video. forked from nypublicradio/audiogram

libplatform.h 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2014 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_LIBPLATFORM_LIBPLATFORM_H_
  5. #define V8_LIBPLATFORM_LIBPLATFORM_H_
  6. #include "libplatform/libplatform-export.h"
  7. #include "libplatform/v8-tracing.h"
  8. #include "v8-platform.h" // NOLINT(build/include)
  9. #include "v8config.h" // NOLINT(build/include)
  10. namespace v8 {
  11. namespace platform {
  12. enum class IdleTaskSupport { kDisabled, kEnabled };
  13. enum class InProcessStackDumping { kDisabled, kEnabled };
  14. enum class MessageLoopBehavior : bool {
  15. kDoNotWait = false,
  16. kWaitForWork = true
  17. };
  18. /**
  19. * Returns a new instance of the default v8::Platform implementation.
  20. *
  21. * The caller will take ownership of the returned pointer. |thread_pool_size|
  22. * is the number of worker threads to allocate for background jobs. If a value
  23. * of zero is passed, a suitable default based on the current number of
  24. * processors online will be chosen.
  25. * If |idle_task_support| is enabled then the platform will accept idle
  26. * tasks (IdleTasksEnabled will return true) and will rely on the embedder
  27. * calling v8::platform::RunIdleTasks to process the idle tasks.
  28. * If |tracing_controller| is nullptr, the default platform will create a
  29. * v8::platform::TracingController instance and use it.
  30. */
  31. V8_PLATFORM_EXPORT std::unique_ptr<v8::Platform> NewDefaultPlatform(
  32. int thread_pool_size = 0,
  33. IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
  34. InProcessStackDumping in_process_stack_dumping =
  35. InProcessStackDumping::kDisabled,
  36. std::unique_ptr<v8::TracingController> tracing_controller = {});
  37. /**
  38. * Pumps the message loop for the given isolate.
  39. *
  40. * The caller has to make sure that this is called from the right thread.
  41. * Returns true if a task was executed, and false otherwise. Unless requested
  42. * through the |behavior| parameter, this call does not block if no task is
  43. * pending. The |platform| has to be created using |NewDefaultPlatform|.
  44. */
  45. V8_PLATFORM_EXPORT bool PumpMessageLoop(
  46. v8::Platform* platform, v8::Isolate* isolate,
  47. MessageLoopBehavior behavior = MessageLoopBehavior::kDoNotWait);
  48. /**
  49. * Runs pending idle tasks for at most |idle_time_in_seconds| seconds.
  50. *
  51. * The caller has to make sure that this is called from the right thread.
  52. * This call does not block if no task is pending. The |platform| has to be
  53. * created using |NewDefaultPlatform|.
  54. */
  55. V8_PLATFORM_EXPORT void RunIdleTasks(v8::Platform* platform,
  56. v8::Isolate* isolate,
  57. double idle_time_in_seconds);
  58. /**
  59. * Attempts to set the tracing controller for the given platform.
  60. *
  61. * The |platform| has to be created using |NewDefaultPlatform|.
  62. *
  63. */
  64. V8_PLATFORM_EXPORT V8_DEPRECATE_SOON(
  65. "Access the DefaultPlatform directly",
  66. void SetTracingController(
  67. v8::Platform* platform,
  68. v8::platform::tracing::TracingController* tracing_controller));
  69. } // namespace platform
  70. } // namespace v8
  71. #endif // V8_LIBPLATFORM_LIBPLATFORM_H_