<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>159626</bug_id>
          
          <creation_ts>2016-07-11 07:34:25 -0700</creation_ts>
          <short_desc>Implement RunLoop::runNowIfMainThreadOrDispatch</short_desc>
          <delta_ts>2016-07-21 09:10:26 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>159552</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Philippe Normand">pnormand</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>calvaris</cc>
    
    <cc>cgarcia</cc>
    
    <cc>commit-queue</cc>
    
    <cc>pnormand</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1209646</commentid>
    <comment_count>0</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2016-07-11 07:34:25 -0700</bug_when>
    <thetext>+++ This bug was initially created as a clone of Bug #159552 +++</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1210242</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2016-07-12 16:47:38 -0700</bug_when>
    <thetext>It&apos;s been a few times before that I wanted such functionality, but then convinced myself that it shouldn&apos;t be added. It would be pretty hard to know about code without knowing whether a block executes right away or races with other code in the function.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1210353</commentid>
    <comment_count>2</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-07-13 00:39:39 -0700</bug_when>
    <thetext>I&apos;m not sure either, and in any case I don&apos;t this would belong to RunLoop class, this could probably be a function on MainThread</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1210360</commentid>
    <comment_count>3</comment_count>
    <who name="Xabier Rodríguez Calvar">calvaris</who>
    <bug_when>2016-07-13 01:21:34 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; It&apos;s been a few times before that I wanted such functionality, but then
&gt; convinced myself that it shouldn&apos;t be added. It would be pretty hard to know
&gt; about code without knowing whether a block executes right away or races with
&gt; other code in the function.

Yes, I understand the concern, which is not that important if you use a debugger and step into the function to see if it is run immediately. We write functions because they are a way to avoid duplicating code. The block:

if (isMainThread()) {
// do
} else
 RunLoop()...

happens a lot and I think it can be simplified in many places.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1210361</commentid>
    <comment_count>4</comment_count>
    <who name="Xabier Rodríguez Calvar">calvaris</who>
    <bug_when>2016-07-13 01:22:46 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; I&apos;m not sure either, and in any case I don&apos;t this would belong to RunLoop
&gt; class, this could probably be a function on MainThread

I thought of RunLoop because it is the one with the dispatch, but it is true that MainThread could be a better place.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>