Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
54ae85ba
Commit
54ae85ba
authored
12 years ago
by
Dmitry Simonenko
Browse files
Options
Downloads
Patches
Plain Diff
coeio: asio refactoring and review fixes.
parent
97b01659
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/coeio.h
+68
-0
68 additions, 0 deletions
include/coeio.h
src/CMakeLists.txt
+1
-1
1 addition, 1 deletion
src/CMakeLists.txt
src/coeio.m
+218
-0
218 additions, 0 deletions
src/coeio.m
src/tarantool.m
+3
-3
3 additions, 3 deletions
src/tarantool.m
with
290 additions
and
4 deletions
include/coeio.h
0 → 100644
+
68
−
0
View file @
54ae85ba
#ifndef TARANTOOL_COEIO_H_INCLUDED
#define TARANTOOL_COEIO_H_INCLUDED
/*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include
"config.h"
#include
<stdbool.h>
#include
<stdint.h>
#include
<stdarg.h>
#include
<unistd.h>
#include
<tarantool_ev.h>
#include
<tarantool_eio.h>
#include
<coro.h>
#include
<util.h>
#include
<rlist.h>
/**
* Asynchronous IO Tasks (libeio wrapper)
*
* Yield the current fiber until a created task is complete.
*/
/**
* A single task' context.
*/
struct
coeio_req
{
struct
eio_req
*
req
;
struct
fiber
*
f
;
bool
complete
;
bool
wait
;
void
*
f_data
;
void
*
result
;
struct
rlist
link
;
};
void
coeio_init
(
void
);
void
coeio_free
(
void
);
struct
coeio_req
*
coeio_custom
(
void
(
*
f
)(
eio_req
*
),
void
*
arg
);
void
*
coeio_wait
(
struct
coeio_req
*
r
);
#endif
/* TARANTOOL_COEIO_H_INCLUDED */
This diff is collapsed.
Click to expand it.
src/CMakeLists.txt
+
1
−
1
View file @
54ae85ba
...
...
@@ -111,7 +111,7 @@ set (common_sources
sio.m
evio.m
coio.m
as
io.m
coe
io.m
iobuf.m
coio_buf.m
salloc.m
...
...
This diff is collapsed.
Click to expand it.
src/coeio.m
0 → 100644
+
218
−
0
View file @
54ae85ba
/*
*
Redistribution
and
use
in
source
and
binary
forms
,
with
or
*
without
modification
,
are
permitted
provided
that
the
following
*
conditions
are
met
:
*
*
1.
Redistributions
of
source
code
must
retain
the
above
*
copyright
notice
,
this
list
of
conditions
and
the
*
following
disclaimer
.
*
*
2.
Redistributions
in
binary
form
must
reproduce
the
above
*
copyright
notice
,
this
list
of
conditions
and
the
following
*
disclaimer
in
the
documentation
and
/
or
other
materials
*
provided
with
the
distribution
.
*
*
THIS
SOFTWARE
IS
PROVIDED
BY
<
COPYRIGHT
HOLDER
>
`
`AS
IS
''
AND
*
ANY
EXPRESS
OR
IMPLIED
WARRANTIES
,
INCLUDING
,
BUT
NOT
LIMITED
*
TO
,
THE
IMPLIED
WARRANTIES
OF
MERCHANTABILITY
AND
FITNESS
FOR
*
A
PARTICULAR
PURPOSE
ARE
DISCLAIMED
.
IN
NO
EVENT
SHALL
*
<
COPYRIGHT
HOLDER
>
OR
CONTRIBUTORS
BE
LIABLE
FOR
ANY
DIRECT
,
*
INDIRECT
,
INCIDENTAL
,
SPECIAL
,
EXEMPLARY
,
OR
CONSEQUENTIAL
*
DAMAGES
(
INCLUDING
,
BUT
NOT
LIMITED
TO
,
PROCUREMENT
OF
*
SUBSTITUTE
GOODS
OR
SERVICES
;
LOSS
OF
USE
,
DATA
,
OR
PROFITS
;
OR
*
BUSINESS
INTERRUPTION
)
HOWEVER
CAUSED
AND
ON
ANY
THEORY
OF
*
LIABILITY
,
WHETHER
IN
CONTRACT
,
STRICT
LIABILITY
,
OR
TORT
*
(
INCLUDING
NEGLIGENCE
OR
OTHERWISE
)
ARISING
IN
ANY
WAY
OUT
OF
*
THE
USE
OF
THIS
SOFTWARE
,
EVEN
IF
ADVISED
OF
THE
POSSIBILITY
OF
*
SUCH
DAMAGE
.
*/
#include
"coeio.h"
#include
"fiber.h"
#include
"exception.h"
#include
<
rlist
.
h
>
#include
<
errno
.
h
>
#include
<
stdio
.
h
>
#include
<
stdlib
.
h
>
#include
<
string
.
h
>
/*
*
Asynchronous
IO
Tasks
(
libeio
wrapper
)
.
*
---
*
*
Libeio
request
processing
is
designed
in
edge
-
trigger
*
manner
,
when
libeio
is
ready
to
process
some
requests
it
*
calls
coeio
_
poller
callback
.
*
*
Due
to
libeio
design
,
coeio
_
poller
is
called
while
locks
*
are
being
held
,
so
it
'
s
unable
to
call
any
libeio
function
*
inside
this
callback
.
*
*
coeio
_
poller
triggers
coeio
_
watcher
to
start
the
polling
process
.
*
In
case
if
none
of
the
requests
are
complete
by
that
time
,
it
*
starts
idle
_
watcher
,
which
would
periodically
invoke
eio
_
poll
*
until
any
of
requests
are
complete
.
*
*
See
for
details
:
*
http
://
pod
.
tst
.
eu
/
http
://
cvs
.
schmorp
.
de
/
libeio
/
eio
.
pod
*/
struct
coeio
_
manager
{
ev
_
idle
coeio
_
repeat
_
watcher
;
ev
_
async
coeio
_
watcher
;
struct
rlist
active
;
}
;
static
struct
coeio
_
manager
coeio
_
manager
;
static
void
coeio
_
schedule
_
repeat
(
struct
ev
_
idle
*
w
,
int
events
__
attribute
__
((
unused
)))
{
if
(
eio
_
poll
()
!=
-
1
)
ev
_
idle
_
stop
(
w
)
;
}
static
void
coeio
_
schedule
(
struct
ev
_
async
*
w
__
attribute
__
((
unused
))
,
int
events
__
attribute
__
((
unused
)))
{
if
(
eio
_
poll
()
==
-
1
)
ev
_
idle
_
start
(
&
coeio
_
manager
.
coeio
_
repeat
_
watcher
)
;
}
static
void
coeio
_
poller
(
void
)
{
ev
_
async
_
send
(
&
coeio
_
manager
.
coeio
_
watcher
)
;
}
/**
*
Init
coeio
subsystem
.
*
*
Create
idle
and
async
watchers
,
init
eio
.
*/
void
coeio
_
init
(
void
)
{
memset
(
&
coeio
_
manager
,
0
,
sizeof
(
struct
coeio
_
manager
))
;
rlist
_
init
(
&
coeio
_
manager
.
active
)
;
ev
_
idle
_
init
(
&
coeio
_
manager
.
coeio
_
repeat
_
watcher
,
coeio
_
schedule
_
repeat
)
;
ev
_
async
_
init
(
&
coeio
_
manager
.
coeio
_
watcher
,
coeio
_
schedule
)
;
ev
_
async
_
start
(
&
coeio
_
manager
.
coeio
_
watcher
)
;
eio
_
init
(
coeio
_
poller
,
NULL
)
;
}
/**
*
Cancel
active
tasks
and
free
memory
.
*/
void
coeio
_
free
(
void
)
{
struct
coeio
_
req
*
r
;
struct
coeio
_
req
*
r
_
next
;
/*
cancel
active
requests
*/
r
=
rlist
_
first
_
entry
(
&
coeio
_
manager
.
active
,
struct
coeio
_
req
,
link
)
;
while
(
1
)
{
if
(
r
==
rlist
_
last
_
entry
(
&
coeio
_
manager
.
active
,
struct
coeio
_
req
,
link
))
break
;
r
_
next
=
rlist
_
next
_
entry
(
r
,
link
)
;
/*
eio
_
cancel
sets
task
as
cancelled
,
this
guarantees
*
that
coeio
_
on
_
complete
would
never
be
called
for
*
this
request
,
thus
we
are
allowed
to
free
memory
here
.
*/
eio
_
cancel
(
r
->
req
)
;
free
(
r
)
;
r
=
r
_
next
;
}
}
inline
static
struct
coeio
_
req
*
coeio
_
alloc
(
void
)
{
struct
coeio
_
req
*
r
=
calloc
(
1
,
sizeof
(
struct
coeio
_
req
))
;
if
(
r
==
NULL
)
{
tnt
_
raise
(
LoggedError
,
:
ER
_
MEMORY
_
ISSUE
,
sizeof
(
struct
coeio
_
req
)
,
"coeio_alloc"
,
"coeio_req"
)
;
}
rlist
_
init
(
&
r
->
link
)
;
return
r
;
}
static
int
coeio
_
on
_
complete
(
eio
_
req
*
req
)
{
struct
coeio
_
req
*
r
=
req
->
data
;
struct
fiber
*
f
=
r
->
f
;
r
->
complete
=
true
;
rlist
_
del
_
entry
(
r
,
link
)
;
if
(
r
->
wait
)
fiber
_
wakeup
(
f
)
;
return
0
;
}
/**
*
Create
new
eio
task
with
specified
libeio
function
and
*
argument
.
*
*
@
throws
ER
_
MEMORY
_
ISSUE
*
*
@
return
coeio
object
pointer
.
*
*
@
code
*
static
void
request
(
eio
_
req
*
req
)
{
*
(
void
)
req
->
data
;
//
"arg"
*
*
req
->
result
=
"result"
;
*
}
*
*
struct
coeio
_
req
*
r
=
coeio
_
custom
(
request
,
"arg"
)
;
*
*/
struct
coeio
_
req
*
coeio
_
custom
(
void
(*f)(eio_req*)
,
void
*
arg
)
{
struct
coeio
_
req
*
r
=
coeio
_
alloc
()
;
r
->
f
=
fiber
;
r
->
f
_
data
=
arg
;
r
->
req
=
eio
_
custom
(
f
,
0
,
coeio
_
on
_
complete
,
r
)
;
if
(
r
->
req
==
NULL
)
{
tnt
_
raise
(
LoggedError
,
:
ER
_
MEMORY
_
ISSUE
,
sizeof
(
struct
eio
_
req
)
,
"coeio_custom"
,
"eio_req"
)
;
}
rlist
_
add
_
tail
_
entry
(
&
coeio
_
manager
.
active
,
r
,
link
)
;
return
r
;
}
/**
*
Yield
and
wait
for
a
request
completion
.
*
*
@
throws
FiberCancelException
*
*
@
return
request
result
pointer
.
*
*
@
code
*
struct
coeio
_
req
*
r
=
coeio
_
custom
(
callback
,
NULL
)
;
*
*
//
wait
for
result
and
free
request
object
*
void
*
result
=
coeio
_
wait
(
r
)
;
*
*
//
continue
with
result
*/
void
*
coeio
_
wait
(
struct
coeio
_
req
*
r
)
{
if
(
r
->
complete
)
{
void
*
result
=
r
->
result
;
free
(
r
)
;
return
result
;
}
r
->
wait
=
true
;
fiber
_
yield
()
;
void
*
result
=
r
->
result
;
free
(
r
)
;
fiber
_
testcancel
()
;
return
result
;
}
This diff is collapsed.
Click to expand it.
src/tarantool.m
+
3
−
3
View file @
54ae85ba
...
...
@@ -48,7 +48,7 @@
#include
<admin.h>
#include
<replication.h>
#include
<fiber.h>
#include
<
as
io.h>
#include
<
coe
io.h>
#include
<iproto.h>
#include
<latch.h>
#include
<recovery.h>
...
...
@@ -593,7 +593,7 @@ tarantool_free(void)
destroy_tarantool_cfg
(
&
cfg
);
fiber_free
();
as
io_free
();
coe
io_free
();
palloc_free
();
ev_default_destroy
();
#ifdef ENABLE_GCOV
...
...
@@ -610,7 +610,7 @@ initialize(double slab_alloc_arena, int slab_alloc_minimal, double slab_alloc_fa
if
(
!
salloc_init
(
slab_alloc_arena
*
(
1
<<
30
),
slab_alloc_minimal
,
slab_alloc_factor
))
panic_syserror
(
"can't initialize slab allocator"
);
fiber_init
();
as
io_init
();
coe
io_init
();
}
static
void
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment