Beispiel #1
0
void _xdispatch_run_iter_wrap(
    void *dt,
    size_t index
)
{
    XDISPATCH_ASSERT( dt );
    iteration_wrap *wrap = static_cast< iteration_wrap * > ( dt );
    XDISPATCH_ASSERT( wrap );

    try
    {
        ( *( wrap->operation() ) )( index );
    }
    catch( const std::exception &e )
    {
        std::cerr << "##################################################################" << std::endl;
        std::cerr << "           Queue '" << xdispatch::current_queue().label() << "'" << std::endl;
        std::cerr << "xdispatch: Throwing exceptions within an xdispatch::operation is" << std::endl;
        std::cerr << "           not recommended, please make sure to catch them before:\n" << std::endl;
        std::cerr << e.what() << std::endl;
        std::cerr << "##################################################################" << std::endl;
        throw;
    }
    catch( ... )
    {
        std::cerr << "##################################################################" << std::endl;
        std::cerr << "           Queue '" << xdispatch::current_queue().label() << "'" << std::endl;
        std::cerr << "xdispatch: Throwing exceptions within an xdispatch::operation is" << std::endl;
        std::cerr << "           not recommended, please make sure to catch them before!" << std::endl;
        std::cerr << "##################################################################" << std::endl;
        std::terminate();
    }
} // _xdispatch_run_iter_wrap
Beispiel #2
0
void _xdispatch_run_operation(
    void *dt
)
{
    XDISPATCH_ASSERT( dt );
    operation *w = static_cast< operation * > ( dt );
    XDISPATCH_ASSERT( w );

    try
    {
        ( *w )();
    }
    catch( const std::exception &e )
    {
        std::cerr << "##################################################################" << std::endl;
        std::cerr << "           Queue '" << xdispatch::current_queue().label() << "'" << std::endl;
        std::cerr << "xdispatch: Throwing exceptions within an xdispatch::operation is" << std::endl;
        std::cerr << "           not recommended, please make sure to catch them before:\n" << std::endl;
        std::cerr << e.what() << std::endl;
        std::cerr << "##################################################################" << std::endl;
        throw;
    }
    catch( ... )
    {
        std::cerr << "##################################################################" << std::endl;
        std::cerr << "           Queue '" << xdispatch::current_queue().label() << "'" << std::endl;
        std::cerr << "xdispatch: Throwing exceptions within an xdispatch::operation is" << std::endl;
        std::cerr << "           not recommended, please make sure to catch them before!" << std::endl;
        std::cerr << "##################################################################" << std::endl;
        std::terminate();
    }
    if( w->auto_delete() )
        delete w;
} // _xdispatch_run_operation
Beispiel #3
0
semaphore::semaphore (
    int val
)
    : d( new data )
{
    XDISPATCH_ASSERT( d.get() );
    d->native = dispatch_semaphore_create( val );
    XDISPATCH_ASSERT( d->native );
}
Beispiel #4
0
semaphore::semaphore (
    dispatch_semaphore_t sem
)
    : d( new data )
{
    XDISPATCH_ASSERT( sem );
    XDISPATCH_ASSERT( d.get() );
    d->native = sem;
    dispatch_retain( sem );
}
Beispiel #5
0
queue::queue (
    const std::string &label
)
    : object(),
      d( new data )
{
    XDISPATCH_ASSERT( d.get() );
    d->native = dispatch_queue_create( label.c_str(), NULL );
    XDISPATCH_ASSERT( d->native );
    d->label = label;
}
Beispiel #6
0
queue::queue (
    dispatch_queue_t q
)
    : object(),
      d( new data )
{
    XDISPATCH_ASSERT( d.get() );
    dispatch_retain( q );
    d->native = q;
    XDISPATCH_ASSERT( d->native );
    d->label = std::string( dispatch_queue_get_label( q ) );
}
Beispiel #7
0
queue::queue (
    const char *label
)
    : object(),
      d( new data )
{
    XDISPATCH_ASSERT( label );
    XDISPATCH_ASSERT( d.get() );
    d->native = dispatch_queue_create( label, NULL );
    XDISPATCH_ASSERT( d->native );
    d->label = std::string( label );
}
Beispiel #8
0
semaphore::semaphore (
    const semaphore &other
)
    : d( new data( *other.d ) )
{
    XDISPATCH_ASSERT( d.get() );
}
Beispiel #9
0
queue::queue (
    const char *label
)
    : m_native( dispatch_queue_create( label, NULL ) ),
      m_label( label )
{
    XDISPATCH_ASSERT( m_native );
}
Beispiel #10
0
once::once (
    dispatch_once_t *dot
)
    : _once_obj( 0 ),
      _once( dot )
{
    XDISPATCH_ASSERT( dot );
}
Beispiel #11
0
queue::queue (
    const queue &other
)
    : object( other ),
      d( new data( *other.d ) )
{
    XDISPATCH_ASSERT( d.get() );
}
Beispiel #12
0
 data (
     const data &other
 )
     : native( other.native )
 {
     XDISPATCH_ASSERT( native );
     dispatch_retain( native );
 }
Beispiel #13
0
queue::queue (
    const std::string &label
)
    : m_native( dispatch_queue_create( label.c_str(), NULL ) ),
      m_label( label )
{
    XDISPATCH_ASSERT( m_native );
}
Beispiel #14
0
group::group (
    const group &other
)
    : object( other ),
      m_native( other.m_native )
{
    XDISPATCH_ASSERT( m_native );
    dispatch_retain( m_native );
}
Beispiel #15
0
group::group (
    dispatch_group_t g
)
    : object(),
      m_native( g )
{
    XDISPATCH_ASSERT( m_native );
    dispatch_retain( m_native );
}
Beispiel #16
0
__XDISPATCH_USE_NAMESPACE


group::group ()
    : object(),
      m_native( dispatch_group_create() )
{
    XDISPATCH_ASSERT( m_native );
}
Beispiel #17
0
queue::queue (
    const queue &other
)
    : m_native( other.m_native ),
      m_label( other.m_label )
{
    XDISPATCH_ASSERT( m_native );
    dispatch_retain( m_native );
}
Beispiel #18
0
void group::notify(
    operation *r,
    const queue &q
)
{
    dispatch_queue_t nat_q = (dispatch_queue_t)q.native();

    XDISPATCH_ASSERT( nat_q );
    dispatch_group_notify_f( m_native, nat_q, r, _xdispatch_run_operation );
}
Beispiel #19
0
__XDISPATCH_USE_NAMESPACE

iteration_wrap::iteration_wrap (
    iteration_operation *o,
    size_t ct
)
    : op( o ),
      ref( ct )
{
    XDISPATCH_ASSERT( o );
}
Beispiel #20
0
__XDISPATCH_USE_NAMESPACE

queue::queue (
    dispatch_queue_t q
)
    : m_native( q ),
      m_label( dispatch_queue_get_label( q ) )
{
    XDISPATCH_ASSERT( m_native );
    dispatch_retain( m_native );
}
Beispiel #21
0
xdispatch::semaphore & semaphore::operator = (
    const semaphore &other
)
{
    if( *this != other )
    {
        d = pointer< data >::unique( new data( *other.d ) );
        XDISPATCH_ASSERT( d.get() );
    }

    return *this;
}
Beispiel #22
0
xdispatch::queue & queue::operator = (
    const queue &other
)
{
    if( *this != other )
    {
        object::operator = (
            other
        );

        d = pointer< data >::unique( new data( *other.d ) );
        XDISPATCH_ASSERT( d.get() );
    }

    return *this;
}
Beispiel #23
0
group & group::operator = (
    const group &other
)
{
    if( *this != other )
    {
        object::operator = (
            other
        );

        m_native = other.m_native;
        XDISPATCH_ASSERT( m_native );
        dispatch_retain( m_native );
    }

    return *this;
}
Beispiel #24
0
xdispatch::queue & queue::operator = (
    const queue &other
)
{
    if( *this != other )
    {
        object::operator = (
            other
        );

        m_native = other.m_native;
        XDISPATCH_ASSERT( m_native );
        dispatch_retain( m_native );
        m_label = other.m_label;
    }

    return *this;
}