On 9/12/16 3:40 PM, Jim Blandy wrote:
Could you go into more detail here? Either the caller will free it, or the
callee will free it --- but they're both on the same thread.

We have this pretty common pattern for handing references around threads safely:

Main thread:

  RefPtr<SomeRunnable> runnable = new SomeRunnable(myRef.forget());
  someTarget->Dispatch(runnable.forget());

Target thread, runnable's Run method:

RefPtr<ResponseRunnable> runnable = new ResponseRunnable(mMyRef.forget());
  originalThread->Dispatch(runnable.forget());

And then back on the original thread the thing in myRef is worked with again. The idea is to keep that thing alive without ever refcounting it on the target thread, because for example it may not have a threadsafe refcount implementation.

If the callee
puts the reference someplace where another thread will free it, then that's
the operation that needs to be audited.

Right, this all assumes that the Dispatch() calls above are infallible. Which they are, iirc.

-Boris

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to