MainThreadEfl.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  3. * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
  4. * Copyright (C) 2008 Diego Gonzalez
  5. * Copyright (C) 2008 Kenneth Rohde Christiansen
  6. * Copyright (C) 2009-2010 ProFUSION embedded systems
  7. * Copyright (C) 2009-2010 Samsung Electronics
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. Neither the name of Apple Inc. ("Apple") nor the names of
  19. * its contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  23. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  26. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  29. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #include "config.h"
  34. #include "MainThread.h"
  35. #include <Ecore.h>
  36. #include <wtf/OwnPtr.h>
  37. #include <wtf/PassOwnPtr.h>
  38. #include <wtf/StdLibExtras.h>
  39. namespace WTF {
  40. static OwnPtr<Ecore_Pipe>& pipeObject()
  41. {
  42. DEFINE_STATIC_LOCAL(OwnPtr<Ecore_Pipe>, pipeObject, ());
  43. return pipeObject;
  44. }
  45. static void monitorDispatchFunctions(void*, void*, unsigned int)
  46. {
  47. dispatchFunctionsFromMainThread();
  48. }
  49. void initializeMainThreadPlatform()
  50. {
  51. pipeObject() = adoptPtr(ecore_pipe_add(monitorDispatchFunctions, 0));
  52. }
  53. void scheduleDispatchFunctionsOnMainThread()
  54. {
  55. ecore_pipe_write(pipeObject().get(), "", 0);
  56. }
  57. }