Scroom  0.14
async-deleter-tests.cc File Reference
#include <scroom/async-deleter.hh>
#include <iostream>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
#include <scroom/function-additor.hh>
#include <scroom/semaphore.hh>
#include "helpers.hh"
Include dependency graph for async-deleter-tests.cc:

Classes

class  A
 

Functions

static const millisec short_timeout (250)
 
static const millisec long_timeout (2000)
 
 BOOST_AUTO_TEST_CASE (deleter_deletes_asynchronously)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( deleter_deletes_asynchronously  )
63 {
64  Semaphore barrier1;
65  Semaphore destroyed;
66  boost::shared_ptr<A> a = boost::shared_ptr<A>(new A(&barrier1, &destroyed), AsyncDeleter<A>());
67  BOOST_CHECK(!destroyed.P(short_timeout));
68 
69  Semaphore barrier2;
70  Semaphore signal;
71  CpuBound()->schedule(pass(&barrier2) + destroy(a) + clear(&signal));
72  a.reset();
73  barrier2.V();
74  BOOST_CHECK(signal.P(long_timeout));
75  BOOST_CHECK(!destroyed.P(short_timeout));
76  barrier1.V();
77  BOOST_CHECK(destroyed.P(long_timeout));
78 }
Here is the call graph for this function:

◆ long_timeout()

static const millisec long_timeout ( 2000  )
static

Referenced by BOOST_AUTO_TEST_CASE().

Here is the caller graph for this function:

◆ short_timeout()

static const millisec short_timeout ( 250  )
static

Referenced by BOOST_AUTO_TEST_CASE(), and anonymous_namespace{threadpoolimpl.cc}::ThreadList::wait().

Here is the caller graph for this function:
short_timeout
static const millisec short_timeout(250)
clear
boost::function< void()> clear(Semaphore *s)
Definition: helpers.cc:29
destroy
boost::function< void()> destroy(boost::shared_ptr< void > p)
Definition: helpers.cc:31
AsyncDeleter
Definition: async-deleter.hh:41
Scroom::Semaphore::P
void P()
Definition: semaphore.hh:38
CpuBound
ThreadPool::Ptr CpuBound()
Definition: threadpoolimpl.cc:452
Scroom::Semaphore
Definition: semaphore.hh:15
long_timeout
static const millisec long_timeout(2000)
pass
boost::function< void()> pass(Semaphore *s)
Definition: helpers.cc:27
A
Definition: boost-bind.cc:21
Scroom::Semaphore::V
void V()
Definition: semaphore.hh:77