diff options
author | Patrik Nyblom <[email protected]> | 2013-08-16 17:14:25 +0200 |
---|---|---|
committer | Patrik Nyblom <[email protected]> | 2013-08-23 17:03:20 +0200 |
commit | 6d1f1d43aa0a9e0a2cb275ef760339c49518fc69 (patch) | |
tree | c51d17da4e41d64eddb42a4918a3f9d2b5967ded /erts/emulator/beam | |
parent | 7204e78d8d16e41769cfd4b7b4051545052c335e (diff) | |
download | otp-6d1f1d43aa0a9e0a2cb275ef760339c49518fc69.tar.gz otp-6d1f1d43aa0a9e0a2cb275ef760339c49518fc69.tar.bz2 otp-6d1f1d43aa0a9e0a2cb275ef760339c49518fc69.zip |
Create better distribution of files over async threads
The actual port id is used to create a key from the
pointer value which is the ErlDrvPort. To do this
a new driver api function driver_async_port_key is
added and the driver API minor version is updated.
The documentation is updated and the faulty description of
how to spread ports over async threads is updated to
use the new API.
Testcase also added.
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/erl_async.c | 14 | ||||
-rw-r--r-- | erts/emulator/beam/erl_driver.h | 4 |
2 files changed, 17 insertions, 1 deletions
diff --git a/erts/emulator/beam/erl_async.c b/erts/emulator/beam/erl_async.c index 054d1a48f6..e6d72f569b 100644 --- a/erts/emulator/beam/erl_async.c +++ b/erts/emulator/beam/erl_async.c @@ -583,6 +583,20 @@ int erts_async_ready_clean(void *varq, void *val) #endif /* +** Generate a fair async key prom an ErlDrvPort +** The port data gives a fair distribution grom port pointer +** to unsigned integer - to be used in key for driver_async below. +*/ +unsigned int driver_async_port_key(ErlDrvPort port) +{ + ErlDrvTermData td = driver_mk_port(port); + if (td == (ErlDrvTermData) NIL) { + return 0; + } + return (unsigned int) (UWord) internal_port_data(td); +} + +/* ** Schedule async_invoke on a worker thread ** NOTE will be syncrounous when threads are unsupported ** return values: diff --git a/erts/emulator/beam/erl_driver.h b/erts/emulator/beam/erl_driver.h index e280563de1..1ab6e17f56 100644 --- a/erts/emulator/beam/erl_driver.h +++ b/erts/emulator/beam/erl_driver.h @@ -133,7 +133,7 @@ typedef struct { #define ERL_DRV_EXTENDED_MARKER (0xfeeeeeed) #define ERL_DRV_EXTENDED_MAJOR_VERSION 2 -#define ERL_DRV_EXTENDED_MINOR_VERSION 1 +#define ERL_DRV_EXTENDED_MINOR_VERSION 2 /* * The emulator will refuse to load a driver with different major @@ -638,6 +638,8 @@ EXTERN int erl_drv_send_term(ErlDrvTermData port, int len); /* Async IO functions */ +EXTERN unsigned int driver_async_port_key(ErlDrvPort port); + EXTERN long driver_async(ErlDrvPort ix, unsigned int* key, void (*async_invoke)(void*), |