Twitch SDK (Internal)
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
ttv::chat::BitsConfigRepository Class Reference

#include <bitsconfigrepository.h>

Inheritance diagram for ttv::chat::BitsConfigRepository:
ttv::Component ttv::IComponent

Public Types

using LookupCallback = std::function< void(TTV_ErrorCode ec, const std::shared_ptr< BitsConfiguration > &bitsConfiguration)>
 
using LookupId = uint64_t
 
enum  State { State::Uninitialized, State::Initialized, State::ShuttingDown, State::Inert }
 

Public Member Functions

 BitsConfigRepository ()
 
TTV_ErrorCode FetchGlobalBitsConfiguration (LookupCallback callback)
 
TTV_ErrorCode FetchChannelBitsConfiguration (ChannelId channelId, LookupCallback callback)
 
TTV_ErrorCode FetchGlobalBitsConfiguration (LookupCallback callback, LookupId &token)
 
TTV_ErrorCode FetchChannelBitsConfiguration (ChannelId channelId, LookupCallback callback, LookupId &token)
 
TTV_ErrorCode CancelFetch (LookupId token)
 
virtual void Update () override
 
virtual TTV_ErrorCode Shutdown () override
 
virtual std::string GetLoggerName () const override
 
virtual void SetTaskRunner (std::shared_ptr< TaskRunner > taskRunner)
 
std::shared_ptr< TaskRunnerGetTaskRunner ()
 
virtual State GetState () const override
 
virtual TTV_ErrorCode Initialize () override
 

Protected Member Functions

TTV_ErrorCode StartTask (std::shared_ptr< Task > task)
 
void CompleteTask (Task *task)
 
bool IsTaskRunning (Task *task) const
 
virtual void SetState (State state)
 
virtual void SetClientState (State state)
 
virtual void SetServerState (State state)
 

Protected Attributes

ClientServerValue< StatemState
 
std::shared_ptr< TaskRunnermTaskRunner
 
std::vector< std::shared_ptr< Task > > mRunningTasks
 
std::mutex mTaskMutex
 
uint64_t mShutdownTimeMilliseconds
 

Private Member Functions

virtual bool CheckShutdown () override
 
virtual void CompleteShutdown () override
 
TTV_ErrorCode ScheduleLookup ()
 
TTV_ErrorCode CacheBitsConfig (const std::shared_ptr< BitsConfiguration > bitsConfiguration)
 

Private Attributes

Cache< ChannelId, std::shared_ptr< BitsConfiguration > > mBitsConfigCache
 
std::map< ChannelId, std::shared_ptr< CallbackQueue< LookupCallback > > > mPendingBitsConfigLookups
 
std::map< LookupId, ChannelIdmChannelLookups
 
CallbackQueue< LookupCallbackmCancelledBitsConfigLookups
 
LookupId mCurrentLookupId
 
bool mLookupInProgress
 

Member Typedef Documentation

◆ LookupCallback

using ttv::chat::BitsConfigRepository::LookupCallback = std::function<void(TTV_ErrorCode ec, const std::shared_ptr<BitsConfiguration>& bitsConfiguration)>

◆ LookupId

Member Enumeration Documentation

◆ State

enum ttv::IComponent::State
stronginherited
Enumerator
Uninitialized 
Initialized 
ShuttingDown 
Inert 

The component doesn't require shutting down.

Constructor & Destructor Documentation

◆ BitsConfigRepository()

ttv::chat::BitsConfigRepository::BitsConfigRepository ( )

Member Function Documentation

◆ CacheBitsConfig()

TTV_ErrorCode ttv::chat::BitsConfigRepository::CacheBitsConfig ( const std::shared_ptr< BitsConfiguration bitsConfiguration)
private

◆ CancelFetch()

TTV_ErrorCode ttv::chat::BitsConfigRepository::CancelFetch ( LookupId  token)

Cancel the fetching of the bits if the task to fetch the bitsconfioguration hasn't been added to the taskrunner yet.

Parameters
[in]tokenLookupId of the bitsConfiguration fetch to cancel.

◆ CheckShutdown()

virtual bool ttv::chat::BitsConfigRepository::CheckShutdown ( )
overrideprivatevirtual

Reimplemented from ttv::Component.

◆ CompleteShutdown()

virtual void ttv::chat::BitsConfigRepository::CompleteShutdown ( )
overrideprivatevirtual

Reimplemented from ttv::Component.

◆ CompleteTask()

void ttv::Component::CompleteTask ( Task task)
protectedinherited

◆ FetchChannelBitsConfiguration() [1/2]

TTV_ErrorCode ttv::chat::BitsConfigRepository::FetchChannelBitsConfiguration ( ChannelId  channelId,
LookupCallback  callback 
)

Returns channel cached bits config or fetches if needed.

◆ FetchChannelBitsConfiguration() [2/2]

TTV_ErrorCode ttv::chat::BitsConfigRepository::FetchChannelBitsConfiguration ( ChannelId  channelId,
LookupCallback  callback,
LookupId token 
)

◆ FetchGlobalBitsConfiguration() [1/2]

TTV_ErrorCode ttv::chat::BitsConfigRepository::FetchGlobalBitsConfiguration ( LookupCallback  callback)

Returns global cached bits config or fetches if needed.

◆ FetchGlobalBitsConfiguration() [2/2]

TTV_ErrorCode ttv::chat::BitsConfigRepository::FetchGlobalBitsConfiguration ( LookupCallback  callback,
LookupId token 
)

Fetch the bits configuration with a cancellation token.

Parameters
[out]tokenLookupId of the bitsConfiguration fetch to (possibly) cancel later with CancelFetch.

◆ GetLoggerName()

virtual std::string ttv::chat::BitsConfigRepository::GetLoggerName ( ) const
overridevirtual

Implements ttv::Component.

◆ GetState()

virtual State ttv::Component::GetState ( ) const
overridevirtualinherited

Implements ttv::IComponent.

◆ GetTaskRunner()

std::shared_ptr<TaskRunner> ttv::Component::GetTaskRunner ( )
inlineinherited

◆ Initialize()

virtual TTV_ErrorCode ttv::Component::Initialize ( )
overridevirtualinherited

◆ IsTaskRunning()

bool ttv::Component::IsTaskRunning ( Task task) const
protectedinherited

◆ ScheduleLookup()

TTV_ErrorCode ttv::chat::BitsConfigRepository::ScheduleLookup ( )
private

◆ SetClientState()

virtual void ttv::Component::SetClientState ( State  state)
protectedvirtualinherited

◆ SetServerState()

virtual void ttv::Component::SetServerState ( State  state)
protectedvirtualinherited

◆ SetState()

virtual void ttv::Component::SetState ( State  state)
protectedvirtualinherited

◆ SetTaskRunner()

virtual void ttv::Component::SetTaskRunner ( std::shared_ptr< TaskRunner taskRunner)
virtualinherited

◆ Shutdown()

virtual TTV_ErrorCode ttv::chat::BitsConfigRepository::Shutdown ( )
overridevirtual

Reimplemented from ttv::Component.

◆ StartTask()

TTV_ErrorCode ttv::Component::StartTask ( std::shared_ptr< Task task)
protectedinherited

◆ Update()

virtual void ttv::chat::BitsConfigRepository::Update ( )
overridevirtual

Reimplemented from ttv::Component.

Member Data Documentation

◆ mBitsConfigCache

Cache<ChannelId, std::shared_ptr<BitsConfiguration> > ttv::chat::BitsConfigRepository::mBitsConfigCache
private

◆ mCancelledBitsConfigLookups

CallbackQueue<LookupCallback> ttv::chat::BitsConfigRepository::mCancelledBitsConfigLookups
private

◆ mChannelLookups

std::map<LookupId, ChannelId> ttv::chat::BitsConfigRepository::mChannelLookups
private

◆ mCurrentLookupId

LookupId ttv::chat::BitsConfigRepository::mCurrentLookupId
private

◆ mLookupInProgress

bool ttv::chat::BitsConfigRepository::mLookupInProgress
private

◆ mPendingBitsConfigLookups

std::map<ChannelId, std::shared_ptr<CallbackQueue<LookupCallback> > > ttv::chat::BitsConfigRepository::mPendingBitsConfigLookups
private

◆ mRunningTasks

std::vector<std::shared_ptr<Task> > ttv::Component::mRunningTasks
protectedinherited

◆ mShutdownTimeMilliseconds

uint64_t ttv::Component::mShutdownTimeMilliseconds
protectedinherited

◆ mState

ClientServerValue<State> ttv::Component::mState
protectedinherited

◆ mTaskMutex

std::mutex ttv::Component::mTaskMutex
mutableprotectedinherited

◆ mTaskRunner

std::shared_ptr<TaskRunner> ttv::Component::mTaskRunner
protectedinherited

The documentation for this class was generated from the following file: