Граф коммитов

14 Коммитов

Автор SHA1 Сообщение Дата
Lina Cambridge faf2fd15e4 Bug 1639018 - Change `TaskRunnable::dispatch` to take owned runnables. r=froydnj
This matches how the `Dispatch(already_AddRefed<nsIRunnable>)`
overloads work in C++: `Dispatch` takes ownership of the runnable, and
leaks it if dispatch fails—because the thread manager is shutting down,
for instance. This avoids a race where a runnable can be released on
either the owning or target thread.

Rust doesn't allow arbitrary `Self` types yet (see
rust-lang/rust#44874), so we need to change `dispatch` and
`dispatch_with_options` to be associated methods.

Differential Revision: https://phabricator.services.mozilla.com/D75858
2020-05-20 20:54:49 +00:00
Lina Cambridge 28cc6477f4 Bug 1638929 - Expose `NS_DispatchBackgroundTask` to `moz_task`. r=KrisWright
Differential Revision: https://phabricator.services.mozilla.com/D75838
2020-05-20 20:54:11 +00:00
Lina Cambridge 80920e5871 Bug 1625286 - Expose dispatch flags to `moz_task`. r=KrisWright
This commit adds a `dispatch_with_options` method to Rust task
runnables, which takes a builder-style `DispatchOptions`
argument controlling how the runnable should be dispatched.
Currently, the only supported option is `may_block`, which
corresponds to `nsIEventTarget::DISPATCH_EVENT_MAY_BLOCK`.

Differential Revision: https://phabricator.services.mozilla.com/D68688

--HG--
extra : moz-landing-system : lando
2020-03-30 19:24:08 +00:00
Lina Cambridge 9697819fb5 Bug 1622082 - Expose `NS_CreateBackgroundTaskQueue` to `moz_task`. r=KrisWright
This commit moves `NS_CreateBackgroundTaskQueue` into an `extern "C"`
block, adds a `create_background_task_queue` function to `moz_task`,
and makes it possible to dispatch Rust `TaskRunnable`s to any event
target, instead of just an `nsIThread`.

Differential Revision: https://phabricator.services.mozilla.com/D66700

--HG--
extra : moz-landing-system : lando
2020-03-13 21:15:51 +00:00
Sylvestre Ledru 3551670431 Bug 1617369 - Reformat xpcom using rustfmt r=froydnj
Depends on D63955

Differential Revision: https://phabricator.services.mozilla.com/D63956

--HG--
extra : moz-landing-system : lando
2020-02-25 16:17:12 +00:00
Emilio Cobos Álvarez 3bb02fa89f Bug 1546048 - Use std::ffi::CStr and the cstr crate instead of custom stuff in xpcom. r=lina
Also, this checks for strings with nulls, which is nice (though I guess an
uncommon mistake).

Differential Revision: https://phabricator.services.mozilla.com/D28312

--HG--
extra : moz-landing-system : lando
2019-04-22 05:09:23 +00:00
Lina Cambridge 6bef7b8477 Bug 1542528 - Add an `xpcom::c_str` macro for creating static C strings. r=froydnj
This is based on the `c_str` macro in `js/rust/src/heap.rs`, but
returns a `NulTerminatedCStr` type that can be cast to a pointer.

This commit also changes `ThreadPtrHolder::new` to take a
`NulTerminatedCStr`, and removes an unnecessary `RefPtr` reference in
`is_current_thread`.

Differential Revision: https://phabricator.services.mozilla.com/D26429

--HG--
extra : moz-landing-system : lando
2019-04-08 14:43:35 +00:00
Kirk Steuber a7dfa5cde2 Bug 1535377 - Allow the xpcom_method Rust macro to be used without importing ensure_param r=myk,froydnj
This is done by incorporating the ensure_param macro into the implementation of the xpcom_method macro

Differential Revision: https://phabricator.services.mozilla.com/D23568

--HG--
extra : moz-landing-system : lando
2019-03-25 18:56:17 +00:00
Lina Cambridge 35f0c7a7f9 Bug 1482608 - Add owning thread pointer holders for Rust code. r=nika,myk
This commit adds `ThreadPtr{Handle, Holder}` to wrap an `XpCom` object
with thread-safe refcounting. These are analagous to
`nsMainThreadPtr{Handle, Holder}`, but can hold references to
objects from any thread, not just the main thread.

`ThreadPtrHolder` is similar to `ThreadBoundRefPtr`. However, it's
not possible to clone a `ThreadBoundRefPtr`, so it can't be shared
among tasks. This is fine for objects that are only used once, like
callbacks. However, `ThreadBoundRefPtr` doesn't work well for loggers
or event emitters, which might need to be called multiple times on
the owning thread.

Unlike a `ThreadBoundRefPtr`, it's allowed and expected to
clone and drop a `ThreadPtrHolder` on other threads. Internally,
the holder keeps an atomic refcount, and releases the wrapped object
on the owning thread once the count reaches zero.

This commit also changes `TaskRunnable` to support dispatching from
threads other than the main thread.

Differential Revision: https://phabricator.services.mozilla.com/D20074

--HG--
extra : moz-landing-system : lando
2019-03-25 04:49:24 +00:00
Nika Layzell f2d9e32b48 Bug 1530028 - Remove now-unnecessary NsresultExt trait, r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D20880

--HG--
extra : moz-landing-system : lando
2019-02-25 15:50:14 +00:00
Gurzau Raul fbe889dd73 Backed out changeset f18666cc5793 (bug 1530028) for build bustages on a CLOSED TREE. 2019-02-25 16:55:00 +02:00
Nika Layzell f4b66e3031 Bug 1530028 - Remove now-unnecessary NsresultExt trait, r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D20880

--HG--
extra : moz-landing-system : lando
2019-02-25 00:23:17 +00:00
Myk Melez 3a0aa679dd Bug 1525392 - update rkv (and LMDB) to their latest stable versions r=froydnj
Changes to rkv and LMDB crates:

rkv 0.7.0 -> 0.9.1
lmdb-rkv 0.9.0 -> 0.11.2
lmdb-sys 0.8.0 -> lmdb-rkv-sys 0.8.2

Update to the LMDB C library:

LMDB 0.9.21 -> 0.9.23 (+ backported patch for Mozilla build issue)

Other crate dependency update:

lazy_static 1.0.1 -> 1.2.0

This also removes the workaround for bug 1525219 and updates the kvstore in-tree crate (and nsIKeyValueService XPCOM API) for the rkv changes.

Differential Revision: https://phabricator.services.mozilla.com/D19094

--HG--
rename : third_party/rust/lmdb-rkv/Cargo.toml => third_party/rust/lmdb-rkv-sys/Cargo.toml
rename : third_party/rust/lmdb-sys/build.rs => third_party/rust/lmdb-rkv-sys/build.rs
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/CHANGES => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/CHANGES
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/COPYRIGHT => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/COPYRIGHT
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/Doxyfile => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/Doxyfile
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/LICENSE => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/LICENSE
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/Makefile => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/Makefile
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/intro.doc => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/intro.doc
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/lmdb.h => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/lmdb.h
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mdb.c => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb.c
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mdb_copy.1 => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb_copy.1
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mdb_copy.c => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb_copy.c
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mdb_dump.1 => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb_dump.1
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mdb_dump.c => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb_dump.c
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mdb_load.1 => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb_load.1
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mdb_load.c => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb_load.c
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mdb_stat.1 => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb_stat.1
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mdb_stat.c => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mdb_stat.c
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/midl.c => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/midl.c
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/midl.h => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/midl.h
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mtest.c => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mtest.c
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mtest2.c => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mtest2.c
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mtest3.c => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mtest3.c
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mtest4.c => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mtest4.c
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mtest5.c => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mtest5.c
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/mtest6.c => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/mtest6.c
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/sample-bdb.txt => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/sample-bdb.txt
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/sample-mdb.txt => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/sample-mdb.txt
rename : third_party/rust/lmdb-sys/lmdb/libraries/liblmdb/tooltag => third_party/rust/lmdb-rkv-sys/lmdb/libraries/liblmdb/tooltag
rename : third_party/rust/lmdb-sys/src/constants.rs => third_party/rust/lmdb-rkv-sys/src/constants.rs
rename : third_party/rust/lmdb-sys/src/ffi.rs => third_party/rust/lmdb-rkv-sys/src/ffi.rs
rename : third_party/rust/lmdb-sys/src/lib.rs => third_party/rust/lmdb-rkv-sys/src/lib.rs
extra : moz-landing-system : lando
2019-02-11 19:53:28 +00:00
Myk Melez 4db9ccb1af Bug 1490496 - implement XPCOM FFI for key-value storage r=nika,lina,mossop
MozReview-Commit-ID: JnQzXG581DW

Differential Revision: https://phabricator.services.mozilla.com/D6328

--HG--
rename : third_party/rust/crossbeam-utils/.cargo-checksum.json => third_party/rust/crossbeam-utils-0.3.2/.cargo-checksum.json
rename : third_party/rust/crossbeam-utils/CHANGELOG.md => third_party/rust/crossbeam-utils-0.3.2/CHANGELOG.md
rename : third_party/rust/crossbeam-utils/Cargo.toml => third_party/rust/crossbeam-utils-0.3.2/Cargo.toml
rename : third_party/rust/crossbeam-utils/LICENSE-MIT => third_party/rust/crossbeam-utils-0.3.2/LICENSE-MIT
rename : third_party/rust/crossbeam-utils/README.md => third_party/rust/crossbeam-utils-0.3.2/README.md
rename : third_party/rust/crossbeam-utils/src/cache_padded.rs => third_party/rust/crossbeam-utils-0.3.2/src/cache_padded.rs
rename : third_party/rust/crossbeam-utils/src/consume.rs => third_party/rust/crossbeam-utils-0.3.2/src/consume.rs
rename : third_party/rust/crossbeam-utils/src/lib.rs => third_party/rust/crossbeam-utils-0.3.2/src/lib.rs
rename : third_party/rust/crossbeam-utils/src/scoped.rs => third_party/rust/crossbeam-utils-0.3.2/src/scoped.rs
rename : third_party/rust/crossbeam-utils/src/consume.rs => third_party/rust/crossbeam-utils/src/atomic/consume.rs
rename : third_party/rust/crossbeam-utils/Cargo.toml => third_party/rust/threadbound/Cargo.toml
rename : third_party/rust/crossbeam-utils/LICENSE-MIT => third_party/rust/threadbound/LICENSE-MIT
rename : third_party/rust/uuid/.cargo-checksum.json => third_party/rust/uuid-0.6.5/.cargo-checksum.json
rename : third_party/rust/uuid/CODE_OF_CONDUCT.md => third_party/rust/uuid-0.6.5/CODE_OF_CONDUCT.md
rename : third_party/rust/uuid/Cargo.toml => third_party/rust/uuid-0.6.5/Cargo.toml
rename : third_party/rust/crossbeam-utils/LICENSE-MIT => third_party/rust/uuid-0.6.5/LICENSE-MIT
rename : third_party/rust/uuid/README.md => third_party/rust/uuid-0.6.5/README.md
rename : third_party/rust/uuid/benches/parse_str.rs => third_party/rust/uuid-0.6.5/benches/parse_str.rs
rename : third_party/rust/uuid/src/adapter.rs => third_party/rust/uuid-0.6.5/src/adapter.rs
rename : third_party/rust/uuid/src/core_support.rs => third_party/rust/uuid-0.6.5/src/core_support.rs
rename : third_party/rust/uuid/src/lib.rs => third_party/rust/uuid-0.6.5/src/lib.rs
rename : third_party/rust/uuid/src/prelude.rs => third_party/rust/uuid-0.6.5/src/prelude.rs
rename : third_party/rust/uuid/src/serde_support.rs => third_party/rust/uuid-0.6.5/src/serde_support.rs
rename : third_party/rust/uuid/src/slog_support.rs => third_party/rust/uuid-0.6.5/src/slog_support.rs
rename : third_party/rust/uuid/src/std_support.rs => third_party/rust/uuid-0.6.5/src/std_support.rs
rename : third_party/rust/uuid/src/test_util.rs => third_party/rust/uuid-0.6.5/src/test_util.rs
rename : third_party/rust/uuid/src/u128_support.rs => third_party/rust/uuid-0.6.5/src/u128_support.rs
rename : third_party/rust/uuid/benches/parse_str.rs => third_party/rust/uuid/benches/invalid_parse_str.rs
rename : third_party/rust/uuid/src/std_support.rs => third_party/rust/uuid/src/parser/std_support.rs
extra : moz-landing-system : lando
2019-02-07 16:14:04 +00:00