Beast improvements and vflib compatibility module work

* Add CallQueue vflib compatibility class
* Use run instead of run_one
* Merge BindableServiceQueue into CallQueue
* Take BEAST_VARIADIC_MAX into account
* Fix license headers as suggested by Vinnie
* Remove obsolete comment
* Add ManualServiceQueue
* Add ManualServiceQueue to beast_vflib include
* Move static unit test variables of header only classes to module cpp
* Remove no longer used mutex member
* _VARIADIC_MAX maxes out at 10
* Correctly apply BEAST_VARIADIC_MAX
* Merge BindableServiceQueue into CallQueue
* New GuiServiceQueue and its JUCE dependency
* Fix leftover merge errors
* Fix CallQueue unit test
* Don't use bassert for better CI support
This commit is contained in:
Patrick Dehne
2013-10-24 17:31:18 +02:00
committed by Vinnie Falco
parent bf87614fa6
commit 08aa415c66
31 changed files with 1069 additions and 283 deletions

View File

@@ -2,6 +2,7 @@
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Copyright Patrick Dehne <patrick@mysonicweb.de> (www.sonicweb-radio.de)
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -20,72 +21,72 @@
#ifndef BEAST_VFLIB_THREADWITHSERVICEQUEUE_H_INCLUDED
#define BEAST_VFLIB_THREADWITHSERVICEQUEUE_H_INCLUDED
#include "BindableServiceQueue.h"
#include "CallQueue.h"
namespace beast {
/** TODO: Queued calls no longer interrupt the idle method at the moment
use an explicit call to interrupt() if you want to also interrupt the
idle method when queuing calls
*/
class ThreadWithServiceQueue
: public BindableServiceQueue
, public Thread
class ThreadWithServiceQueue
: public CallQueue
{
public:
/** Entry points for a ThreadWithCallQueue.
*/
class EntryPoints
{
public:
/** Entry points for a ThreadWithCallQueue.
*/
class EntryPoints
{
public:
virtual ~EntryPoints () { }
virtual ~EntryPoints () { }
virtual void threadInit () { }
virtual void threadInit () { }
virtual void threadExit () { }
virtual bool threadIdle ()
{
bool interrupted = false;
return interrupted;
}
};
explicit ThreadWithServiceQueue (const String& name);
~ThreadWithServiceQueue();
void start (EntryPoints* const entryPoints);
void stop (bool const wait);
// Should be called periodically by the idle function.
// There are two possible results:
//
// #1 Returns false. The idle function may continue or return.
// #2 Returns true. The idle function should return as soon as possible.
//
// May only be called on the service queue thead
bool interruptionPoint ();
/* Interrupts the idle function.
*/
void interrupt ();
private:
void run ();
void doInterrupt ();
void doWakeUp ();
private:
EntryPoints* m_entryPoints;
bool m_calledStart;
bool m_calledStop;
bool m_interrupted;
CriticalSection m_mutex;
virtual void threadExit () { }
};
explicit ThreadWithServiceQueue (const String& name);
~ThreadWithServiceQueue();
void start (EntryPoints* const entryPoints);
void stop (bool const wait);
/** Calls all functors in the queue. Blocks if there are no
functors available to run until more functors become
available or the queue is stopped
*/
bool synchronize ();
/** Helper class to work around ThreadWithServiceQueue and Thread both
having a run member
*/
class Worker
: public Thread
{
public:
Worker(const String& name, ThreadWithServiceQueue *parent)
: Thread(name)
, m_parent(parent)
{
}
void run()
{
m_parent->runThread();
}
private:
ThreadWithServiceQueue *m_parent;
};
void runThread ();
private:
EntryPoints* m_entryPoints;
bool m_calledStart;
bool m_calledStop;
Worker m_thread;
};
}
#endif