►
From YouTube: Node.js N-API Team meeting - Apri 8 2019
Description
A
So
welcome
to
the
napi,
a
team
meeting
for
April
8th
2019
today
we're
going
to
take
a
little
bit
of
a
different
approach
than
our
usual
meetings,
we'll
start
off
with
there's
any
announcements
or
anything
like
that.
But
then
we're
gonna
focus
the
rest
of
the
meeting
on
an
issue
around
a
sink
workers.
So
before
we
get
started,
does
anybody
have
any
announcements
they'd
like
to
make.
C
D
A
F
That's
right,
yeah
yeah,
so
I'm
not
sure
how
to
do
that,
like.
How
do
you
check
if
something
is
allocated?
I
mean.
A
A
Like
you
could
do
it
a
couple
ways
like
that
you
could,
you
know
basically
have
something
that
says:
no,
you
have
to
provide
us
yeah,
you
can.
Oh
here's
a
method.
You
can
call
we'll
give
you
an
answer.
That
means
we
know,
we've
always
allocated
it
and
therefore
it's
it.
The
delete
can
match
that
yeah,
because.
A
F
D
F
A
So
the
you
know
one
approach
to
we
could
say
we
could
dock
that.
Well,
you
have
to
keep
allocate
it
if
you
want
to
have
it
be
self
destructed.
If
we
did
that,
though,
I
think
the
other
thing
we
need
to
do
is
figure
out
a
pattern
where
they
provide
the
destructor
right
instead,
I
think.
Currently
our
cone
goes
and
deletes
it
right.
Yeah.
F
F
F
D
F
Then
the
destructor
for
for
async
worker
is
public
virtual,
so
you
can
override
it
in
your
subclass
with
a
method
that
does
nothing,
but
you
must,
if
you,
if
you
wish
for
it,
if
you
wish
for
it
to
behave
otherwise
like.
If
you
wish
to
stack
allocated,
then
you
must
override
that
come
the
destructor,
otherwise
it'll
it'll
destroy
itself,
and
your
memory
too.
So.
G
F
E
H
G
F
Yeah,
okay,
because
this
substance
is
a
threat
the
suppress
destruct
is
for
is
for
something
else:
the
suppress
destructors
for
for
destroying
itself
on
on
work
complete.
So
it
calls
the
on
okay
Dion
error
and
then
it
destroys
itself.
So,
okay,
whereas
the
destructor
is,
is
a
little
bit
later
in
the
game.
Okay,
so
yeah!
That's
that's
a
good
point.
We
could.
We
could
probably,
instead
of
delete
self,
we
could
say
like
self
arrow
delete
and
then
that
could
be
a
method
that
potentially
does
nothing.
F
B
F
F
Right,
yeah,
well,
yeah,
I,
don't
know
we
do
it.
Anybody
use
malloc
with
the
class
but
but
yeah.
If
they
have
something
some
other
sort
of
allocator,
then
yeah,
then
then
this
would
be.
This
would
be
more
generic
yeah,
okay,
I!
That's
that's
a
that's
an
item
we
can
break
out,
have
a
more
generic
sort
of
leader.
A
F
H
F
Yeah
yeah
yeah
calling
it
well,
we
could
we
could
well,
we
could
make
it
I
mean
if
we
made
it
like
a
protected
method,
then
then
you
know
it
would
be
part
of
the
implementation
of
well
no,
never
mind
yeah.
A
I
F
J
J
A
Of
still
the
same
thing
like
the
same
ideas
like,
but
you
know,
the
final
answer
is
the
one
I
was
thinking
of
us
like
hey
an
object
when
the
objects
no
longer
reference.
We're
gonna
handle
the
deletion
for
you.
This
is
like
okay.
When
the
work
is
complete,
we
will
handle
the
deletion
for
you,
I
guess
the
async
work
heard.
We
don't
have
a
corresponding
and
that's
probably
not
as
good
anyway
like
if
we
had
a
corresponding
object.
You
could
actually
use
something
like
a
finalizar,
but
that's
not
I.
Think.
F
Like
to
finalize
yeah
yeah,
exactly
so
so,
basically,
basically
replace
this
line.
That
says:
delete
self
with
like
with
with
basically
like
self
arrow
delete
where
delete
is,
is,
is
a
function
pointer
or
some
sort
of
you
know,
lambda
or
whatever,
like
a
C++
function
pointer
that
was
passed
in
you're
in
construction
right.
D
F
H
H
D
F
F
Maybe
if
we
implemented
this,
then
we
could
rewrite
async
worker
to
use
it.
And
then
you
know
we
would
point
people
at
this
thing
and
and
then
sort
of
convey
the
message
that
if
and
when
you
get
the
time,
then
you
know
break
the
one
on
one
or
the
one
to
one
with
with
with
man
and
and
use
a
better
interface
yeah.
K
F
F
F
E
K
H
F
F
A
That
seems
like
the
right
answer
to
me.
Like
you
know,
it's
consistent,
because
we
did
it
to
be
consistent
with
men.
It
dis
fixes
a
problem.
That's
there
and
it's
fairly
low
like
it.
Doesn't
it's
not
cember
at
all
right,
assembler,
minor,
right,
yeah,
so
a
sembra
minor,
so
I
mean
I,
think
that's.
It
closes
the
worst
part
of
the
gap.
It
is
consistent
with
man.
It
seems
like
the
right
thing
to
me
versus
a
like,
there's
still
value
in
looking
at
like.
F
A
Just
trying
to
okay,
so
let's
go
back
though,
and
see
what
else
that
that
addresses
right
number
one
so
that
one
we
know.
Okay,
you
can
fix
that
right.
Yeah,
that's
done!
Okay,
the
synchronicity
from
the
callers
lifetime
in
the
object
Carnival
is
a
reference
to
sink,
where
any
calls
cancel
right
so
being
able
to
call
cancel.
A
F
Yeah
yeah
cuz
yeah
the
the
way
in
which
the
way
in
which
these
these
callbacks
execute
that
they
are
fired
from
the
from
the
event
loop
may
correct
me
if
I'm
wrong.
If
I
understand
this
correctly,
though,
the
way
in
which
callbacks
are
executed
from
the
event
loop
may
result
in
the
work
complete
being
called
or
it
may
result
in
in
the
cancel
being
called
after
the
work
complete
has
already
finished,
in
which
case
there
will
probably
be
a
segmentation
fault.
L
F
The
cancel
callback
has
to
account
for
the
fact
that
that
that
the
work
may
have
completed
right
so
so
then,
so
then,
the
the
on
okay
or
on
error
callbacks
are
really
responsible
for
force
for
setting
a
flag
somewhere
that
inform
that
informs
the
cancel
callback.
Well,
it's
too
late
to
cancel
now
right,
because
because
this
this
can
occur,
I
mean
yeah.
H
F
F
H
H
F
H
F
F
Work
takes
a
long
time
right,
but
but
just
before
the
work
finishes,
you
insert
let's
say
an
idol
and
Idol
handler
or
like
a
one-time
timeout
into
the
event
loop,
the
body
of
which
says,
cancel
on
this
instance
right.
So
now
you
have
now.
You
have
two
two
callbacks
in
the
event
loop
right.
The
first
one
is
the
notification
that
the
work
has
completed.
I
see
I,
see
the
second
one
is
the
cancel.
So
that's
the
problem
that.
F
Yeah,
you
don't
know
in
which
order
the
two
callbacks
are
present
in
the
in
the
event
loop.
So
that's
yeah.
So
then
the
second
one
calls
cancel
on
an
object.
That's
already
destroyed.
So
so,
basically,
basically,
if
you
do
cancel
and
if
you
do
cancel
asynchronously,
then
then
you
basically
have
to
have
to
keep
an
object
between
the
two
that
that
has
two
references:
1
1
from
the
instance
and
and
one
from
the
callback
and
and
then
when,
when
both
of
those
references
are
gone,
then
you
delete
the
object.
F
So
you
have
to
have
code
inside
your
instance.
That
said
in
your
destructor,
for
example,
that
says
you
know,
am
I.
The
only
reference
to
this
object
then
delete
it,
because
that
means
the
work
was
cancelled
right
and
then,
and
then
the
the
cancel
callback
has.
A
reference
also
has
a
pointer
to
this
object
and
it
checks
the
references
and
if,
if,
if
there's
only
one
reference,
then
it
means
okay.
The
work
has
completed
it's
too
late
to
cancel
unwrap
the
object
and
delete.
F
A
A
A
F
A
F
No,
it
can't
nevermind
well
it
it
could
be
implemented
in
the
subclass
if
we
also
expose
the
destroy,
because
because
the
subclass
could
implement
ref
and
on
ref
right,
but
then
where
it,
where
essentially
we're
essentially
coaching
people
on
how
to
properly
use
this
rather
than
giving
them
the
tools
to
properly
use
it.
So
what
I'm
saying
is
if
we
expose
destroy
right,
then
the
destroy
could
unrest
this
as
in
itself
right
and
only
destroy
itself,
if
other.
F
D
A
But
I
think
actually
suppress
destruct.
Does
the
same
thing
right,
because,
basically,
if
you,
if
use
then
I'm
going
to
use
this
press
to
suppress
destruct
like
if
you
want
to
use
cancel,
you
have
to
yeah,
you
have
to
use
suppress
just
this
suppress
destruct
every
feelin
all
right
and
you
basically
you're
in
charge
of
doing
it.
So
when
it
actually,
we
won't
delete
it
once
you've
finished
you're
past
the
point
where
you
think
that
you
need
to
cancel
it.
Of
course,
the
thing
they're.
F
F
Callback
got
called
first,
was
it
the
on
work,
complete
or
was
it
to
cancel
right
and
then?
And
then
you
you?
Can
you
can
keep
the
ref
count
right
there?
You
know
you
you,
you,
you
set
the
initial
ref
count
to
and
then
and
you
suppress
destruct
and
then
you
you
dereference
from
cancel
and
you
dereference
from
from
from
work,
complete
and
then
the
last
the
last
reference
when
it's
gone
you
delete.
F
So
basically,
yes,
the
press
destruct
gives
you
the
ability
to
delete
whenever
you
want
to,
and
it
also
takes
care
of
this
race
condition.
As
a
result,
it's
just
it's
not
as
nice,
because
you
have
to
do
the
ref
counting
yourself.
That's
all,
but
we
cannot
do
the
ref
counting
for
you,
because
we
cannot
know
when
you
will
call
cancel
right
right.
A
F
A
D
A
And
well,
no,
that's
probably
not
gonna
work,
but
in
fact,
then,
when
on
ok
was
called
or
or
the
other
one,
we
would
still
do
it
delete
right,
but
it
would
have
fact.
Yes
that
would
effectively
get
us
I.
Think
if
I'm
thinking
it
through
carefully
what
you
want
right
like
you
could
call
up
to
the
point
where
you
want
to
call
cancel
you,
you
don't
call
it
delete
once
you
call
delete
you're
no
longer
allowed
to
call
because.
E
F
F
Think,
there's
a
there's:
a
distinction
between
cancelable
or
no
there's
a
distinction
between
okay.
No
something
has
to
happen
in
response
to
you're
expressing
the
desire
to
to
make
this
operation
cancelable,
because
in
response
to
you
expressing
your
desire
to
make
this
operation
cancel
what
we
need
to
increment.
The
rest
count
well,
but
right,
but.
A
F
F
A
F
So,
okay,
so
let's
say:
okay,
so
let's
say
you
say,
suppress
this
rock
okay
I
see
what
you're
saying.
Okay
I
see
what
you're
saying
so
so,
okay!
So
basically,
what
you're
saying
is:
okay,
suppress
this
okay,
the
ref
count
when
you
create
the
instance.
Is
one
yeah
you
you,
you
call
suppress
destruct
the
ref
count.
Rises.
F
Explicitly
because
you
can't
suppress
this
drug
all
right,
okay,
but
can
we
accommodate?
Can
we
accommodate
an
auto
destructing
one
while
still
solving
this
and
I
think
the
only
way
we
can
do?
That
is
if
we,
if
we
expose
or
if
we
create
an
API,
whereby
you
inform
that
there's
a
there's,
an
asynchronous
outstanding
cancel
that
will
potentially
open.
A
Without
looking,
you
right,
I
think
if
you
just
know,
because
I
think
I
mean
you
create
you,
create
it
and
call
suppress
to
stuff
destruct,
and
we
now
have
so
now
we
have
our
f
cattitude
right
yeah.
Then
you
can
either
at
some
time
later
say:
okay,
you
can
can't
you
can
call,
cancel
or
not,
because
I
think
the
thing
is
you
may
or
may
not
know
that
you
want
to
cancel
it,
but
up
to
a
certain
point
you
make
you
want
to
contain
the
option
to
try
and
cancel
right
yep
after
a
certain.
A
A
There'll
be
other
methods
that
want
to
do
something
similar,
but
like
basically,
I
can't
call
anything
on
this,
because
I'm
telling
you
I'm
deleting
right,
yeah
and
then
once
you've
done,
that
it
goes
down
to
one,
and
it
means
that
if
the
on
ok
or
on
error
has
already
run,
it
will
be
deleted
immediately.
Right.
A
F
A
A
A
F
No
you're
right
right
right,
but
but
that's
up
yeah,
if
it's,
if
it's,
if
okay
I
see
what
you
mean
so
so
you
basically
you
queue
it
and
then
you
delete
it
right.
F
Yeah,
that's
that's
an
interesting
point.
Ok
did
this
is
actually
a
different
problem
because,
because
I,
how
do
we
handle
this?
Even
on
the
sea
side
like
on
the
on
the
sea
side,
you
you
there's.
Obviously
there
are
objects
in
the
background,
but
but
the
API
doesn't
allow
you
to
actually
delete
those
object.
All
it
allows
you
to
do
is
cancel
the
work
like
you
have
no
control
over
the
pointer
on
the
sea
side
right
because
you
have
this
and
nappy
async
work.
F
A
F
Right
look
delete.
F
A
Nope
all
it
does
is
delete
right.
So
it's
it's
basically
that
you
can't
delete
it.
You
can't
call
like
once
you
call
delete
you're
out
of
luck
right,
yeah.
D
F
F
B
F
F
F
Yeah
yeah
yeah,
so
so
so
yeah
I
mean
we're
not
gonna
use
that
javascript
object
anymore.
So
it's
not
available
anymore.
That's,
basically
what
we're
saying
but
I'm
not
seeing
anything.
Actually,
you
know
update
the
thread
pool
and
all
that
stuff.
You
know
removing
remove
removing
handles
from
the
event
loop
and
all
that
stuff
right.
So
that's
still
still
gonna
run
well,
maybe
not!
Let's
where's
the
implementation
of
thread
pool
work.
F
Yeah
we've
got,
there
is
no,
nothing
happens
during
the
destruction
of
it,
so,
okay,
so
okay,
so
let
me
see
I
think
that's.
This
is
the
only
threat
for
work
stuff
here
in
node,
internals,
dot
H.
So
so
then
so
then
they're
no
effort
is
being
made
to
actually
remove
stuff
from
the
queue
it
looks
like.
A
F
Right,
yeah
yeah,
so
so
yeah,
so
you
can't
oh
well
in
line
virtual
threat,
tilde
threat
to
work
equals
default.
So
what
to
do
in
the
case
of
of
destruction
is
left
up
to
the
implementer.
Basically,
so,
let's
see
what
some
of
these
implementers
do
like,
for
example,
you
have
note
crypto,
anodes
adlib,
and
these
guys,
let's
see
if
they
provide.
E
M
F
F
D
F
It
looks
like
once
you've
queued
it,
you
pretty
much
cannot
delete
it
until
you've
received
some
some
feedback
saying
you
know
it
has
completed
or
not.
You
can
cancel
it
and
then
that
that
will
ultimately
call
UV
cancel,
but
but
that's
a
that's
an
operation
that
in
that
assumes
the
work
is
intact.
So
it
cannot
be
part
of
the
destruction
of
everything
right.