20#include <isode/base/compat.h>
22#define DEFAULTMANAGER EVENTSVC_POLLMANAGER
25#define DEFAULTSTREAMPROVIDER "socketpoll"
26#define DEFAULTDATAGRAMPROVIDER "socketpoll"
30#include "../include/AsyncObject.h"
32#include <isode/messages/base.h>
35 pthread_mutex_t *mutex;
38 MutexLock (pthread_mutex_t *mp) : mutex(mp) {
39 if ( pthread_mutex_lock (mutex) != 0 ) {
40 MSG_Base_Tmutexlock_LOG (
"event mutex");
45 if ( pthread_mutex_unlock (mutex) != 0 ) {
46 MSG_Base_Tunlock_LOG (
"event mutex");
51IC_CDECL
int EventServiceInit (
52 const char *managertype,
53 const char *pollertype,
59 rc = ::Event::Manager::ManagerFactory (managertype, msp);
73 const int Manager::MAXPRIO;
75 Manager *Manager::_instance;
76 static pthread_mutex_t manager_mutex = PTHREAD_MUTEX_INITIALIZER;
78 int Manager::ManagerFactory (
const char *type, MSGstruct *msp)
82 if ( _instance != 0 ) {
83 MSG_IOevent_ManagerCreated_LOG ();
88 type = DEFAULTMANAGER;
90 if ( strcmp (type, EVENTSVC_THREADMANAGER) == 0 ) {
91 _instance = CreateThreadManager ();
96 if ( strcmp (type, EVENTSVC_POLLMANAGER) == 0 ) {
97 _instance = CreatePollManager ();
102 MSG_IOevent_Managertype_SET (msp, type);
103 return MSG_IOevent_Managertype;
109 Provider *Provider::instance;
110 static pthread_mutex_t poller_mutex = PTHREAD_MUTEX_INITIALIZER;
116 if ( instance != 0 ) {
117 MSG_IOevent_PollProviderCreated_LOG ();
121 if ( type == 0 || strcmp (type,
"epoll") == 0 ) {
122 instance = CreatePollepollProvider ();
127 if ( type == 0 || strcmp (type,
"port") == 0 ) {
128 instance = CreatePollportProvider ();
133 if ( type == 0 || strcmp (type,
"poll") == 0 ) {
134 instance = CreatePollpollProvider ();
139 if ( type == 0 || strcmp (type,
"select") == 0 ) {
140 instance = CreatePollselectProvider ();
145 MSG_IOevent_PollProvidertype_SET (msp, type);
146 return MSG_IOevent_PollProvidertype;
156 type = DEFAULTSTREAMPROVIDER;
158 if ( strcmp (type,
"socketpoll") == 0 ) {
164 return CreateSocketPollProvider ();
167 MSG_IOevent_StreamProvidertype_SET (msp, type);
178 type = DEFAULTDATAGRAMPROVIDER;
180 if ( strcmp (type,
"socketpoll") == 0 ) {
186 return CreateSocketPollProvider ();
189 MSG_IOevent_StreamProvidertype_SET (msp, type);
197IC_CDECL
void EventServiceRun (
void)
199 Event::Manager::GetManager()->Run(
false);
203IC_CDECL
void EventAsyncDispatch (
void (*func)(
void *),
void *param)
205 Event::AsyncObject::Invoke (
reinterpret_cast<Event::AsyncObject::FuncPtr
>(func),
210IC_CDECL
void EventServiceLongLived (
void)
212 Event::Manager::GetManager()->LongLived();
215IC_CDECL
void EventServiceTerminate (
int millisecs)
217 Event::Manager::GetManager()->Terminate(millisecs);
Provider of a stream interface.
static EVENTSVC_DLL Provider * ProviderFactory(const char *type, MSGstruct *msp)
Factory method for Stream provider.
static int ProviderFactory(const char *type, MSGstruct *msg)
Factory method.for stream provider.
static Provider * GetPollService()
Implement as a singleton.
Provider of a stream interface.
static EVENTSVC_DLL Provider * ProviderFactory(const char *type, MSGstruct *msp)
Factory method for Stream provider.
Interface between a user of a datagram service and its provider.
Interface between a user of a stream and the provider of a stream.