Skip to content

Commit 75af1e5

Browse files
committed
Grammatical fixes.
1 parent 60260b6 commit 75af1e5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

doc/guide-ffi.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,15 @@ which would call back to `callback()` in Rust.
303303

304304
## Targetting callbacks to Rust objects
305305

306-
The former example showed how a global function can be called from C-Code.
306+
The former example showed how a global function can be called from C code.
307307
However it is often desired that the callback is targetted to a special
308308
Rust object. This could be the object that represents the wrapper for the
309309
respective C object.
310310

311311
This can be achieved by passing an unsafe pointer to the object down to the
312312
C library. The C library can then include the pointer to the Rust object in
313-
the notification. This will provide a unsafe possibility to access the
314-
referenced Rust object in callback.
313+
the notification. This will allow the callback to unsafely access the
314+
referenced Rust object.
315315

316316
Rust code:
317317
~~~~ {.xfail-test}
@@ -364,25 +364,25 @@ void trigger_callback() {
364364

365365
## Asynchronous callbacks
366366

367-
In the already given examples the callbacks are invoked as a direct reaction
367+
In the previously given examples the callbacks are invoked as a direct reaction
368368
to a function call to the external C library.
369-
The control over the current thread switched from Rust to C to Rust for the
369+
The control over the current thread is switched from Rust to C to Rust for the
370370
execution of the callback, but in the end the callback is executed on the
371371
same thread (and Rust task) that lead called the function which triggered
372372
the callback.
373373

374-
Things get more complicated when the external library spawns it's own threads
374+
Things get more complicated when the external library spawns its own threads
375375
and invokes callbacks from there.
376-
In these cases access to Rust data structures inside he callbacks is
376+
In these cases access to Rust data structures inside the callbacks is
377377
especially unsafe and proper synchronization mechanisms must be used.
378-
Besides classical synchronization mechanisms like mutexes one possibility in
378+
Besides classical synchronization mechanisms like mutexes, one possibility in
379379
Rust is to use channels (in `std::comm`) to forward data from the C thread
380380
that invoked the callback into a Rust task.
381381

382382
If an asychronous callback targets a special object in the Rust address space
383383
it is also absolutely necessary that no more callbacks are performed by the
384-
C library after the respective Rust object get's destroyed.
385-
This can be achieved by unregistering the callback it the object's
384+
C library after the respective Rust object gets destroyed.
385+
This can be achieved by unregistering the callback in the object's
386386
destructor and designing the library in a way that guarantees that no
387387
callback will be performed after unregistration.
388388

0 commit comments

Comments
 (0)