template < class FunctionTraits,
class ReturnType=typename FunctionTraits::result_type,
- unsigned arity=FunctionTraits::arity >
+ unsigned arity=FunctionTraits::arity >
class ParsedCommandOverload;
template < class Overload,
/* We don't take POLLIN/POLLOUT as argument to avoid having to include
sys/poll.h in the .cci file (and therefore indirectly into the .hh
and then every file which uses FileHandle) */
-prefix_ bool senf::FileBody::pollCheck(int fd, bool incoming, bool block, bool oob)
+prefix_ bool senf::FileBody::pollCheck(int fd, bool incoming, int timeout, bool oob)
const
{
struct ::pollfd pfd;
pfd.events = incoming?(oob?POLLPRI:POLLIN):POLLOUT;
int rv = -1;
do {
- rv = ::poll(&pfd,1,block?-1:0);
+ rv = ::poll(&pfd,1,timeout);
if (rv<0)
switch (errno) {
case EINTR:
prefix_ bool senf::FileBody::readable()
const
{
- return pollCheck(fd(),true);
+ return pollCheck(fd(),true,0);
}
-prefix_ void senf::FileBody::waitReadable()
+prefix_ bool senf::FileBody::waitReadable(senf::ClockService::clock_type timeout)
const
{
- pollCheck(fd(),true,true);
+ return pollCheck(fd(), true,
+ (timeout==-1?-1:senf::ClockService::in_milliseconds(timeout)) );
}
prefix_ bool senf::FileBody::writeable()
const
{
- return pollCheck(fd(),false);
+ return pollCheck(fd(),false,0);
}
-prefix_ void senf::FileBody::waitWriteable()
+prefix_ bool senf::FileBody::waitWriteable(senf::ClockService::clock_type timeout)
const
{
- pollCheck(fd(),false,true);
+ return pollCheck(fd(), false,
+ (timeout==-1?-1:senf::ClockService::in_milliseconds(timeout)) );
}
prefix_ bool senf::FileBody::oobReadable()
const
{
- return pollCheck(fd(),true,false,true);
+ return pollCheck(fd(),true,0,true);
}
-prefix_ void senf::FileBody::waitOOBReadable()
+prefix_ bool senf::FileBody::waitOOBReadable(senf::ClockService::clock_type timeout)
const
{
- pollCheck(fd(),true,true,true);
+ return pollCheck(fd(), true,
+ (timeout==-1?-1:senf::ClockService::in_milliseconds(timeout)), true);
}
///////////////////////////////////////////////////////////////////////////
return body().readable();
}
-prefix_ void senf::FileHandle::waitReadable()
+prefix_ bool senf::FileHandle::waitReadable(senf::ClockService::clock_type timeout)
const
{
- body().waitReadable();
+ return body().waitReadable(timeout);
}
prefix_ bool senf::FileHandle::writeable()
return body().writeable();
}
-prefix_ void senf::FileHandle::waitWriteable()
+prefix_ bool senf::FileHandle::waitWriteable(senf::ClockService::clock_type timeout)
const
{
- body().waitWriteable();
+ return body().waitWriteable(timeout);
}
prefix_ bool senf::FileHandle::oobReadable()
return body().oobReadable();
}
-prefix_ void senf::FileHandle::waitOOBReadable()
+prefix_ bool senf::FileHandle::waitOOBReadable(senf::ClockService::clock_type timeout)
const
{
- body().waitOOBReadable();
+ return body().waitOOBReadable(timeout);
}
prefix_ bool senf::FileHandle::blocking()
// Custom includes
#include <memory> // std::auto_ptr
#include "../Utils/safe_bool.hh"
+#include "../Scheduler/ClockService.hh"
//#include "FileHandle.mpp"
///////////////////////////////hh.p////////////////////////////////////////
bool readable() const; ///< Check, whether a read on the handle would not block
///< (ignoring blocking state)
- void waitReadable() const; ///< Wait, until read on the handle would not block (ignoring
+ bool waitReadable(senf::ClockService::clock_type timeout = -1) const;
+ ///< Wait, until read on the handle would not block (ignoring
///< blocking state)
+ /**< \param[in] timeout max time to wait, default is to wait
+ forever.
+ \returns \c true, if handle became readable or \c false on
+ timeout. */
bool writeable() const; ///< Check, whether a write on the handle would not block
///< (ignoring blocking state)
- void waitWriteable() const; ///< Wait, until a write on the handle would not block
+ bool waitWriteable(senf::ClockService::clock_type timeout = -1) const;
+ ///< Wait, until a write on the handle would not block
///< (ignoring blocking state)
+ /**< \param[in] timeout max time to wait, default is to wait
+ forever.
+ \returns \c true, if handle became writable or \c false on
+ timeout. */
bool oobReadable() const; ///< Check, whether a read of prioritized data on the handle
///< would not block (ignoring blocking state)
- void waitOOBReadable() const; ///< Wait, until read of prioritized data on the handle does
+ bool waitOOBReadable(senf::ClockService::clock_type timeout = -1) const;
+ ///< Wait, until read of prioritized data on the handle does
///< not block (ignoring blocking state)
+ /**< \param[in] timeout max time to wait, default is to wait
+ forever.
+ \returns \c true, if handle became readable for
+ out-of-band data or \c false on timeout. */
bool blocking() const; ///< Return current blocking state
void blocking(bool status); ///< Set blocking state
void destroyClose();
bool readable() const;
- void waitReadable() const;
+ bool waitReadable(senf::ClockService::clock_type timeout) const;
bool writeable() const;
- void waitWriteable() const;
+ bool waitWriteable(senf::ClockService::clock_type timeout) const;
bool oobReadable() const;
- void waitOOBReadable() const;
+ bool waitOOBReadable(senf::ClockService::clock_type timeout) const;
bool blocking() const;
void blocking(bool status);
protected:
private:
- bool pollCheck(int fd, bool incoming, bool block=false, bool oob=false) const;
+ bool pollCheck(int fd, bool incoming, int timeout, bool oob=false) const;
int fd_;
};
;; Configuration file for cc-ide.el (Emacs C++ IDE extension, see http://g0dil.de)
- (defvar senf-c-style
+(defun check-namespace-indent (arg)
+ (save-excursion
+ (back-to-indentation)
+ (if (looking-at "namespace") [0] '+)))
+
+ (defconst senf-c-style
'((c-basic-offset . 4)
(c-backslash-column . 98)
(c-cleanup-list . (empty-defun-braces
(extern-lang-open after)
(inexpr-class-open after)
(inexpr-class-close before)))
- (c-offsets-alist . ((namespace-open . 0)
- (namespace-close . 0)
- (innamespace . +)
+ (c-offsets-alist . ((namespace-open . [0])
+ (namespace-close . [0])
+ (innamespace . check-namespace-indent)
(statement-block-intro . +)
(substatement-open . 0)
(label . 0)