Commit 48d186c3 authored by Nicholas Bamber's avatar Nicholas Bamber

[svn-upgrade] new version libio-aio-perl (3.80)

parent 56c26e73
......@@ -170,7 +170,7 @@ use common::sense;
use base 'Exporter';
BEGIN {
our $VERSION = '3.71';
our $VERSION = '3.8';
our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close
aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx
......@@ -184,7 +184,7 @@ BEGIN {
our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice));
our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush
min_parallel max_parallel max_idle
min_parallel max_parallel max_idle idle_timeout
nreqs nready npending nthreads
max_poll_time max_poll_reqs
sendfile fadvise madvise
......@@ -260,6 +260,7 @@ documentation.
IO::AIO::min_parallel $nthreads
IO::AIO::max_parallel $nthreads
IO::AIO::max_idle $nthreads
IO::AIO::idle_timeout $seconds
IO::AIO::max_outstanding $maxreqs
IO::AIO::nreqs
IO::AIO::nready
......@@ -486,6 +487,15 @@ Currently, the stats are always 64-bit-stats, i.e. instead of returning an
error when stat'ing a large file, the results will be silently truncated
unless perl itself is compiled with large file support.
To help interpret the mode and dev/rdev stat values, IO::AIO offers the
following constants and functions (if not implemented, the constants will
be C<0> and the functions will either C<croak> or fall back on traditional
behaviour).
C<S_IFMT>, C<S_IFIFO>, C<S_IFCHR>, C<S_IFBLK>, C<S_IFLNK>, C<S_IFREG>,
C<S_IFDIR>, C<S_IFWHT>, C<S_IFSOCK>, C<IO::AIO::major $dev_t>,
C<IO::AIO::minor $dev_t>, C<IO::AIO::makedev $major, $minor>.
Example: Print the length of F</etc/passwd>:
aio_stat "/etc/passwd", sub {
......@@ -596,6 +606,8 @@ The only (POSIX-) portable way of calling this function is:
aio_mknod $path, IO::AIO::S_IFIFO | $mode, 0, sub { ...
See C<aio_stat> for info about some potentially helpful extra constants
and functions.
=item aio_link $srcpath, $dstpath, $callback->($status)
......@@ -1516,10 +1528,11 @@ Under normal circumstances you don't need to call this function.
=item IO::AIO::max_idle $nthreads
Limit the number of threads (default: 4) that are allowed to idle (i.e.,
threads that did not get a request to process within 10 seconds). That
means if a thread becomes idle while C<$nthreads> other threads are also
idle, it will free its resources and exit.
Limit the number of threads (default: 4) that are allowed to idle
(i.e., threads that did not get a request to process within the idle
timeout (default: 10 seconds). That means if a thread becomes idle while
C<$nthreads> other threads are also idle, it will free its resources and
exit.
This is useful when you allow a large number of threads (e.g. 100 or 1000)
to allow for extremely high load situations, but want to free resources
......@@ -1529,6 +1542,11 @@ The default is probably ok in most situations, especially if thread
creation is fast. If thread creation is very slow on your system you might
want to use larger values.
=item IO::AIO::idle_timeout $seconds
Sets the minimum idle timeout (default 10) after which worker threads are
allowed to exit. SEe C<IO::AIO::max_idle>.
=item IO::AIO::max_outstanding $maxreqs
This is a very bad function to use in interactive programs because it
......
......@@ -18,7 +18,7 @@
#include <fcntl.h>
#include <sched.h>
#if _POSIX_MEMLOCK || _POSIX_MAPPED_FILES
#if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES
# include <sys/mman.h>
#endif
......@@ -210,6 +210,31 @@ static HV *aio_stash, *aio_req_stash, *aio_grp_stash;
# define ST_RELATIME 0
#endif
#ifndef S_IFIFO
# define S_IFIFO 0
#endif
#ifndef S_IFCHR
# define S_IFCHR 0
#endif
#ifndef S_IFBLK
# define S_IFBLK 0
#endif
#ifndef S_IFLNK
# define S_IFLNK 0
#endif
#ifndef S_IFREG
# define S_IFREG 0
#endif
#ifndef S_IFDIR
# define S_IFDIR 0
#endif
#ifndef S_IFWHT
# define S_IFWHT 0
#endif
#ifndef S_IFSOCK
# define S_IFSOCK 0
#endif
#ifndef MAP_ANONYMOUS
# ifdef MAP_ANON
# define MAP_ANONYMOUS MAP_ANON
......@@ -233,6 +258,16 @@ static HV *aio_stash, *aio_req_stash, *aio_grp_stash;
# define MAP_NONBLOCK 0
#endif
#ifndef makedev
# define makedev(maj,min) (((maj) << 8) | (min))
#endif
#ifndef major
# define major(dev) ((dev) >> 8)
#endif
#ifndef minor
# define minor(dev) ((dev) & 0xff)
#endif
#ifndef PAGESIZE
# define PAGESIZE sysconf (_SC_PAGESIZE)
#endif
......@@ -639,6 +674,9 @@ static void atfork_child (void)
#if !_POSIX_MAPPED_FILES
# define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1)
# define munmap(addr,length) (errno = ENOSYS, -1)
#endif
#if !_POSIX_MEMORY_PROTECTION
# define mprotect(addr,len,prot) (errno = ENOSYS, -1)
# define PROT_NONE 0
# define PROT_WRITE 0
......@@ -728,9 +766,17 @@ BOOT:
const_iv (O_TRUNC)
const_iv (O_EXCL)
const_iv (O_APPEND)
#ifndef _WIN32
const_iv (S_IFIFO)
#endif
const_iv (S_IFCHR)
const_iv (S_IFBLK)
const_iv (S_IFLNK)
const_iv (S_IFREG)
const_iv (S_IFDIR)
const_iv (S_IFWHT)
const_iv (S_IFSOCK)
const_iv (S_IFMT)
const_niv (FADV_NORMAL , POSIX_FADV_NORMAL)
const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL)
const_niv (FADV_RANDOM , POSIX_FADV_RANDOM)
......@@ -822,7 +868,7 @@ BOOT:
}
void
max_poll_reqs (int nreqs)
max_poll_reqs (unsigned int nreqs)
PROTOTYPE: $
CODE:
eio_set_max_poll_reqs (nreqs);
......@@ -834,25 +880,31 @@ max_poll_time (double nseconds)
eio_set_max_poll_time (nseconds);
void
min_parallel (int nthreads)
min_parallel (unsigned int nthreads)
PROTOTYPE: $
CODE:
eio_set_min_parallel (nthreads);
void
max_parallel (int nthreads)
max_parallel (unsigned int nthreads)
PROTOTYPE: $
CODE:
eio_set_max_parallel (nthreads);
void
max_idle (int nthreads)
max_idle (unsigned int nthreads)
PROTOTYPE: $
CODE:
eio_set_max_idle (nthreads);
void
max_outstanding (int maxreqs)
idle_timeout (unsigned int seconds)
PROTOTYPE: $
CODE:
eio_set_idle_timeout (seconds);
void
max_outstanding (unsigned int maxreqs)
PROTOTYPE: $
CODE:
max_outstanding = maxreqs;
......@@ -1062,6 +1114,22 @@ aio_stat (SV8 *fh_or_path, SV *callback=&PL_sv_undef)
REQ_SEND;
}
UV
major (UV dev)
ALIAS:
minor = 1
CODE:
RETVAL = ix ? major (dev) : minor (dev);
OUTPUT:
RETVAL
UV
makedev (UV maj, UV min)
CODE:
RETVAL = makedev (maj, min);
OUTPUT:
RETVAL
void
aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef)
PPCODE:
......@@ -1526,7 +1594,7 @@ munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef)
addr = (void *)(((intptr_t)addr) + offset);
eio_page_align (&addr, &len);
#if _POSIX_MEMLOCK
#if _POSIX_MEMLOCK_RANGE
RETVAL = munlock (addr, len);
#else
RETVAL = ((errno = ENOSYS), -1);
......
......@@ -10,6 +10,17 @@ TODO: aio_mincore?
TODO: add? also linux-specific stuff?
TODO: O_EXEC O_SEARCH O_CLOEXEC O_DIRECTORY O_DSYNC O_NOCTTY O_NOFOLLOW O_NONBLOCK O_RSYNC O_SYNC O_TTY_INIT O_DIRECT O_LARGEFILE O_NOATIME O_ASYNC
3.8 Sun Mar 27 12:25:33 CEST 2011
- use nonstandard but maybe-working-on-bsd fork technique.
- support a max_idle value of 0.
- support setting of idle timeout value (IO::AIO::idle_timeout).
3.72 Fri Feb 11 04:25:38 CET 2011
- use _POSIX_MEMLOCK_RANGE to detetc mlock/munlock.
- aio_mknod always used a dev_t value of 0.
- new treescan option: --grep.
- add more S_IF macros, and major/minor/makedev "macros".
3.71 Thu Dec 30 08:18:46 CET 2010
- the numerical result value passed to callbacks did not stringify
correctly, due to internal reuse and failure to reset the sv flags.
......
......@@ -28,4 +28,4 @@ configure
autogen.sh
typemap
META.yml Module meta-data (added by MakeMaker)
META.json Module meta-data (added by MakeMaker)
{
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"meta-spec" : {
"version" : 1.4,
"url" : "http://module-build.sourceforge.net/META-spec-v1.4.html"
},
"generated_by" : "ExtUtils::MakeMaker::JSONMETA version 7.000",
"distribution_type" : "module",
"version" : "3.8",
"name" : "IO-AIO",
"author" : [],
"license" : "unknown",
"build_requires" : {
"ExtUtils::MakeMaker" : 0
},
"requires" : {
"common::sense" : 0
},
"abstract" : null,
"configure_requires" : {
"ExtUtils::MakeMaker" : 0
}
}
--- #YAML:1.0
name: IO-AIO
version: 3.71
abstract: ~
author: []
license: unknown
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 0
build_requires:
ExtUtils::MakeMaker: 0
requires:
common::sense: 0
no_index:
directory:
- t
- inc
generated_by: ExtUtils::MakeMaker version 6.56
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
......@@ -206,6 +206,7 @@ FUNCTIONS
IO::AIO::min_parallel $nthreads
IO::AIO::max_parallel $nthreads
IO::AIO::max_idle $nthreads
IO::AIO::idle_timeout $seconds
IO::AIO::max_outstanding $maxreqs
IO::AIO::nreqs
IO::AIO::nready
......@@ -416,6 +417,15 @@ FUNCTIONS
silently truncated unless perl itself is compiled with large file
support.
To help interpret the mode and dev/rdev stat values, IO::AIO offers
the following constants and functions (if not implemented, the
constants will be 0 and the functions will either "croak" or fall
back on traditional behaviour).
"S_IFMT", "S_IFIFO", "S_IFCHR", "S_IFBLK", "S_IFLNK", "S_IFREG",
"S_IFDIR", "S_IFWHT", "S_IFSOCK", "IO::AIO::major $dev_t",
"IO::AIO::minor $dev_t", "IO::AIO::makedev $major, $minor".
Example: Print the length of /etc/passwd:
aio_stat "/etc/passwd", sub {
......@@ -513,6 +523,9 @@ FUNCTIONS
aio_mknod $path, IO::AIO::S_IFIFO | $mode, 0, sub { ...
See "aio_stat" for info about some potentially helpful extra
constants and functions.
aio_link $srcpath, $dstpath, $callback->($status)
Asynchronously create a new link to the existing object at $srcpath
at the path $dstpath and call the callback with the result code.
......@@ -1123,9 +1136,10 @@ FUNCTIONS
IO::AIO::max_idle $nthreads
Limit the number of threads (default: 4) that are allowed to idle
(i.e., threads that did not get a request to process within 10
seconds). That means if a thread becomes idle while $nthreads other
threads are also idle, it will free its resources and exit.
(i.e., threads that did not get a request to process within the idle
timeout (default: 10 seconds). That means if a thread becomes idle
while $nthreads other threads are also idle, it will free its
resources and exit.
This is useful when you allow a large number of threads (e.g. 100 or
1000) to allow for extremely high load situations, but want to free
......@@ -1136,6 +1150,10 @@ FUNCTIONS
creation is fast. If thread creation is very slow on your system you
might want to use larger values.
IO::AIO::idle_timeout $seconds
Sets the minimum idle timeout (default 10) after which worker
threads are allowed to exit. SEe "IO::AIO::max_idle".
IO::AIO::max_outstanding $maxreqs
This is a very bad function to use in interactive programs because
it blocks, and a bad way to reduce concurrency because it is
......
......@@ -11,7 +11,7 @@ our $VERSION = $IO::AIO::VERSION;
Getopt::Long::Configure ("bundling", "no_ignore_case", "require_order", "auto_help", "auto_version");
my ($opt_silent, $opt_print0, $opt_stat, $opt_nodirs, $opt_nofiles);
my ($opt_silent, $opt_print0, $opt_stat, $opt_nodirs, $opt_nofiles, $opt_grep);
GetOptions
"quiet|q" => \$opt_silent,
......@@ -19,13 +19,20 @@ GetOptions
"stat|s" => \$opt_stat,
"dirs|d" => \$opt_nofiles,
"files|f" => \$opt_nodirs,
"grep|g=s" => \$opt_grep,
or die "Usage: try $0 --help";
@ARGV = "." unless @ARGV;
$opt_grep &&= qr{$opt_grep}s;
sub printfn {
my ($prefix, $files, $suffix) = @_;
if ($opt_grep) {
@$files = grep "$prefix$_" =~ $opt_grep, @$files;
}
if ($opt_print0) {
print map "$prefix$_$suffix\0", @$files;
} elsif (!$opt_silent) {
......
......@@ -57,6 +57,10 @@
/* utimes(2) is available */
#undef HAVE_UTIMES
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
......
/*
* libeio implementation
*
* Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libeio@schmorp.de>
* Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libeio@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
......@@ -81,7 +81,7 @@
# include <signal.h>
# include <dirent.h>
#if _POSIX_MEMLOCK || _POSIX_MAPPED_FILES
#if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES
# include <sys/mman.h>
#endif
......@@ -134,9 +134,6 @@
# define D_NAMLEN(de) strlen ((de)->d_name)
#endif
/* number of seconds after which an idle threads exit */
#define IDLE_TIMEOUT 10
/* used for struct dirent, AIX doesn't provide it */
#ifndef NAME_MAX
# define NAME_MAX 4096
......@@ -225,12 +222,13 @@ static unsigned int max_poll_reqs; /* reslock */
static volatile unsigned int nreqs; /* reqlock */
static volatile unsigned int nready; /* reqlock */
static volatile unsigned int npending; /* reqlock */
static volatile unsigned int max_idle = 4;
static volatile unsigned int max_idle = 4; /* maximum number of threads that can idle indefinitely */
static volatile unsigned int idle_timeout = 10; /* number of seconds after which an idle threads exit */
static xmutex_t wrklock = X_MUTEX_INIT;
static xmutex_t reslock = X_MUTEX_INIT;
static xmutex_t reqlock = X_MUTEX_INIT;
static xcond_t reqwait = X_COND_INIT;
static xmutex_t wrklock;
static xmutex_t reslock;
static xmutex_t reqlock;
static xcond_t reqwait;
#if !HAVE_PREADWRITE
/*
......@@ -370,6 +368,14 @@ static ETP_REQ *reqq_shift (etp_reqq *q)
abort ();
}
static void etp_thread_init (void)
{
X_MUTEX_CREATE (wrklock);
X_MUTEX_CREATE (reslock);
X_MUTEX_CREATE (reqlock);
X_COND_CREATE (reqwait);
}
static void etp_atfork_prepare (void)
{
X_LOCK (wrklock);
......@@ -417,12 +423,13 @@ static void etp_atfork_child (void)
nready = 0;
npending = 0;
etp_atfork_parent ();
etp_thread_init ();
}
static void
etp_once_init (void)
{
{
etp_thread_init ();
X_THREAD_ATFORK (etp_atfork_prepare, etp_atfork_parent, etp_atfork_child);
}
......@@ -623,7 +630,14 @@ static void etp_set_max_poll_reqs (unsigned int maxreqs)
static void etp_set_max_idle (unsigned int nthreads)
{
if (WORDACCESS_UNSAFE) X_LOCK (reqlock);
max_idle = nthreads <= 0 ? 1 : nthreads;
max_idle = nthreads;
if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock);
}
static void etp_set_idle_timeout (unsigned int seconds)
{
if (WORDACCESS_UNSAFE) X_LOCK (reqlock);
idle_timeout = seconds;
if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock);
}
......@@ -761,6 +775,11 @@ void eio_set_max_idle (unsigned int nthreads)
etp_set_max_idle (nthreads);
}
void eio_set_idle_timeout (unsigned int seconds)
{
etp_set_idle_timeout (seconds);
}
void eio_set_min_parallel (unsigned int nthreads)
{
etp_set_min_parallel (nthreads);
......@@ -1433,18 +1452,9 @@ eio_page_align (void **addr, size_t *length)
}
#if !_POSIX_MEMLOCK
# define eio__mlock(a,b) ((errno = ENOSYS), -1)
# define eio__mlockall(a) ((errno = ENOSYS), -1)
#else
static int
eio__mlock (void *addr, size_t length)
{
eio_page_align (&addr, &length);
return mlock (addr, length);
}
static int
eio__mlockall (int flags)
{
......@@ -1465,6 +1475,20 @@ eio__mlockall (int flags)
}
#endif
#if !_POSIX_MEMLOCK_RANGE
# define eio__mlock(a,b) ((errno = ENOSYS), -1)
#else
static int
eio__mlock (void *addr, size_t length)
{
eio_page_align (&addr, &length);
return mlock (addr, length);
}
#endif
#if !(_POSIX_MAPPED_FILES && _POSIX_SYNCHRONIZED_IO)
# define eio__msync(a,b,c) ((errno = ENOSYS), -1)
#else
......@@ -1548,7 +1572,7 @@ X_THREAD_PROC (etp_proc)
++idle;
ts.tv_sec = time (0) + IDLE_TIMEOUT;
ts.tv_sec = time (0) + idle_timeout;
if (X_COND_TIMEDWAIT (reqwait, reqlock, ts) == ETIMEDOUT)
{
if (idle > max_idle)
......@@ -1678,7 +1702,7 @@ static void eio_execute (etp_worker *self, eio_req *req)
case EIO_RENAME: req->result = rename (req->ptr1, req->ptr2); break;
case EIO_LINK: req->result = link (req->ptr1, req->ptr2); break;
case EIO_SYMLINK: req->result = symlink (req->ptr1, req->ptr2); break;
case EIO_MKNOD: req->result = mknod (req->ptr1, (mode_t)req->int2, (dev_t)req->int3); break;
case EIO_MKNOD: req->result = mknod (req->ptr1, (mode_t)req->int2, (dev_t)req->offs); break;
case EIO_READLINK: ALLOC (PATH_MAX);
req->result = readlink (req->ptr1, req->ptr2, PATH_MAX); break;
......@@ -1938,7 +1962,7 @@ eio_req *eio_readdir (const char *path, int flags, int pri, eio_cb cb, void *dat
eio_req *eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data)
{
REQ (EIO_MKNOD); PATH; req->int2 = (long)mode; req->int3 = (long)dev; SEND;
REQ (EIO_MKNOD); PATH; req->int2 = (long)mode; req->offs = (off_t)dev; SEND;
}
static eio_req *
......
/*
* libeio API header
*
* Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libeio@schmorp.de>
* Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libeio@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
......@@ -182,7 +182,7 @@ struct eio_req
eio_req volatile *next; /* private ETP */
ssize_t result; /* result of syscall, e.g. result = read (... */
off_t offs; /* read, write, truncate, readahead, sync_file_range: file offset */
off_t offs; /* read, write, truncate, readahead, sync_file_range: file offset, mknod: dev_t */
size_t size; /* read, write, readahead, sendfile, msync, mlock, sync_file_range: length */
void *ptr1; /* all applicable requests: pathname, old name; readdir: optional eio_dirents */
void *ptr2; /* all applicable requests: new name or memory buffer; readdir: name strings */
......@@ -192,7 +192,7 @@ struct eio_req
int type; /* EIO_xxx constant ETP */
int int1; /* all applicable requests: file descriptor; sendfile: output fd; open, msync, mlockall, readdir: flags */
long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode, sync_file_range: flags */
long int3; /* chown, fchown: gid; mknod: dev_t */
long int3; /* chown, fchown: gid */
int errorno; /* errno value on syscall return */
unsigned char flags; /* private */
......@@ -241,6 +241,7 @@ void eio_set_max_poll_reqs (unsigned int nreqs);
void eio_set_min_parallel (unsigned int nthreads);
void eio_set_max_parallel (unsigned int nthreads);
void eio_set_max_idle (unsigned int nthreads);
void eio_set_idle_timeout (unsigned int seconds);
unsigned int eio_nreqs (void); /* number of requests in-flight */
unsigned int eio_nready (void); /* number of not-yet handled requests */
......
......@@ -29,6 +29,7 @@ typedef int ssize_t;
#include <windows.h>
#include <pthread.h>
#define sigset_t int
#define sigfillset(a)
#define pthread_sigmask(a,b,c)
#define sigaddset(a,b)
#define sigemptyset(s)
......@@ -36,11 +37,13 @@ typedef int ssize_t;
typedef pthread_mutex_t xmutex_t;
#define X_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
#define X_MUTEX_CREATE(mutex) pthread_mutex_init (&(mutex), 0)
#define X_LOCK(mutex) pthread_mutex_lock (&(mutex))
#define X_UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
typedef pthread_cond_t xcond_t;
#define X_COND_INIT PTHREAD_COND_INITIALIZER
#define X_COND_CREATE(cond) pthread_cond_init (&(cond), 0)
#define X_COND_SIGNAL(cond) pthread_cond_signal (&(cond))
#define X_COND_WAIT(cond,mutex) pthread_cond_wait (&(cond), &(mutex))
#define X_COND_TIMEDWAIT(cond,mutex,to) pthread_cond_timedwait (&(cond), &(mutex), &(to))
......@@ -95,18 +98,27 @@ thread_create (xthread_t *tid, void *(*proc)(void *), void *arg)
typedef pthread_mutex_t xmutex_t;
#if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP)
# define X_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
# define X_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
# define X_MUTEX_CREATE(mutex) \
do { \
pthread_mutexattr_t attr; \
pthread_mutexattr_init (&attr); \
pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_ADAPTIVE_NP); \
pthread_mutex_init (&(mutex), &attr); \
} while (0)
#else
# define X_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
# define X_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
# define X_MUTEX_CREATE(mutex) pthread_mutex_init (&(mutex), 0)
#endif
#define X_LOCK(mutex) pthread_mutex_lock (&(mutex))
#define X_UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
#define X_LOCK(mutex) pthread_mutex_lock (&(mutex))
#define X_UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
typedef pthread_cond_t xcond_t;
#define X_COND_INIT PTHREAD_COND_INITIALIZER
#define X_COND_SIGNAL(cond) pthread_cond_signal (&(cond))
#define X_COND_WAIT(cond,mutex) pthread_cond_wait (&(cond), &(mutex))
#define X_COND_TIMEDWAIT(cond,mutex,to) pthread_cond_timedwait (&(cond), &(mutex), &(to))
#define X_COND_INIT PTHREAD_COND_INITIALIZER
#define X_COND_CREATE(cond) pthread_cond_init (&(cond), 0)
#define X_COND_SIGNAL(cond) pthread_cond_signal (&(cond))
#define X_COND_WAIT(cond,mutex) pthread_cond_wait (&(cond), &(mutex))
#define X_COND_TIMEDWAIT(cond,mutex,to) pthread_cond_timedwait (&(cond), &(mutex), &(to))
typedef pthread_t xthread_t;
#define X_THREAD_PROC(name) static void *name (void *thr_arg)
......
......@@ -5,14 +5,19 @@ use IO::AIO;
# this is a lame test, but....
BEGIN { plan tests => 9 }
BEGIN { plan tests => 10 }
IO::AIO::min_parallel 2;
aio_nop sub {
IO::AIO::aio_nop sub {
print "ok 6\n";
};
IO::AIO::aio_busy 0.2, sub {
print "ok 8\n";
};
print "ok 1\n";
if (open FH, "-|") {
......@@ -22,7 +27,7 @@ if (open FH, "-|") {
};
print "ok 5\n";
IO::AIO::poll while IO::AIO::nreqs;
print "ok 8\n";
print "ok 9\n";
} else {
print "ok 2\n";
aio_stat "/", sub {
......@@ -33,5 +38,5 @@ if (open FH, "-|") {
exit;
}
print "ok 9\n";
print "ok 10\n";
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment