Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
async-deleter-tests.cc File Reference
#include <iostream>
#include <memory>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread.hpp>
#include <gtest/gtest.h>
#include <scroom/async-deleter.hh>
#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)
 
 EXPECT_FALSE (destroyed.P(short_timeout))
 
 CpuBound () -> schedule(pass(&barrier2)+destroy(a)+clear(&signal))
 
a reset ()
 
barrier2 V ()
 
 EXPECT_TRUE (signal.P(long_timeout))
 
 EXPECT_TRUE (destroyed.P(long_timeout))
 

Variables

Semaphore destroyed
 
std::shared_ptr< Aa = std::shared_ptr<A>(new A(&barrier1, &destroyed), AsyncDeleter<A>())
 
Semaphore barrier2
 
Semaphore signal
 

Function Documentation

◆ CpuBound()

CpuBound ( ) -> schedule(pass(&barrier2)+destroy(a)+clear(&signal))

ThreadPool for cpu-bound tasks

This ThreadPool has one thread per core in your system. For CpuBound tasks, this is the optimum. Make sure your tasks do not block or wait for anything.

Returns
a shared pointer to this ThreadPool instance
See also
https://github.com/kees-jan/scroom/wiki/StaticInitializationOrderFiasco
456{
457 static ThreadPool::Ptr const cpuBound = NotifyThreadList<ThreadPool>(std::make_shared<ThreadPool>(), "CpuBound threadpool");
458
459 return cpuBound;
460}
std::shared_ptr< ThreadPool > Ptr
Definition threadpool.hh:165

◆ EXPECT_FALSE()

EXPECT_FALSE ( destroyed.  Pshort_timeout)

◆ EXPECT_TRUE() [1/2]

EXPECT_TRUE ( destroyed.  Plong_timeout)

◆ EXPECT_TRUE() [2/2]

EXPECT_TRUE ( signal.  Plong_timeout)

◆ long_timeout()

static const millisec long_timeout ( 2000  )
static

◆ reset()

a reset ( )
132{
133 testData.reset();
134
135 return false;
136}
TestData::Ptr testData
Definition test-helpers.cc:25

◆ short_timeout()

static const millisec short_timeout ( 250  )
static

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

Here is the caller graph for this function:

◆ V()

s2 V ( )
Initial value:
{
Definition semaphore.hh:16
BitmapSurface::Ptr const s
Definition transformpresentation_test.cc:70

Referenced by Scroom::Bookkeeping::MapBase< K, V >::reReserve(), and Scroom::Bookkeeping::MapBase< K, V >::reserve().

Here is the caller graph for this function:

Variable Documentation

◆ a

◆ barrier2

Semaphore barrier2

◆ destroyed

Semaphore destroyed
Initial value:
{
Semaphore barrier1

◆ signal