version 1.2, 2015/04/20 18:10:13
|
version 1.3, 2015/04/20 18:19:56
|
|
|
| |
#include <common.h> | #include <common.h> |
#include <base/base.h> | #include <base/base.h> |
|
#include <base/Strand.h> |
|
#include <pal/thread.h> |
#include "provmgr.h" | #include "provmgr.h" |
|
#include <pal/lock.h> |
| |
BEGIN_EXTERNC | BEGIN_EXTERNC |
| |
|
#define CONTEXT_STRANDAUX_TRYPOSTLEFT 0 |
|
#define CONTEXT_STRANDAUX_TRYPOSTLEFT_NOTIFY 1 |
|
#define CONTEXT_STRANDAUX_INVOKESUBSCRIBE 2 |
|
|
typedef enum _Context_Type | typedef enum _Context_Type |
{ | { |
CTX_TYPE_SINGLE_ITEM = 0, /* regular execution, post results to the caller */ | CTX_TYPE_SINGLE_ITEM = 0, /* regular execution, post results to the caller */ |
CTX_TYPE_IND_NOTINITIALIZED, /* un-initialized indication context */ |
CTX_TYPE_IND_AGGREGATION, /* indication context (AggregationContext) */ |
CTX_TYPE_IND_READY, /* indication context that is ready for operation */ |
CTX_TYPE_IND_SUBSCRIPTION, /* indication context (SubscriptionContext) */ |
|
CTX_TYPE_IND_LIFECYCLE, /* indication context (LifecycleContext) */ |
|
CTX_TYPE_IND_SUB_UNSUB, /* indication context for invoking Subscribe and Unsubscribe */ |
CTX_TYPE_INVOKE_WITH_INSTANCE /* calling get before invoke - call invoke with result instance */ | CTX_TYPE_INVOKE_WITH_INSTANCE /* calling get before invoke - call invoke with result instance */ |
} | } |
Context_Type; | Context_Type; |
| |
|
// for Context.tryingToPostLeft |
|
#define CONTEXT_POSTLEFT_POSTING 1 // If Context_PostMessageLeft is trying to post to the left |
|
#define CONTEXT_POSTLEFT_SCHEDULED 2 // If CONTEXT_STRANDAUX_POSTLEFT is currently scheduled |
|
|
typedef struct _Context | typedef struct _Context |
{ | { |
MI_Context base; | MI_Context base; |
MI_Uint32 magic; | MI_Uint32 magic; |
| |
|
Strand strand; // manages interaction with the component to the left (dispatcher, agent, etc.) |
|
Lock lock; |
|
Message * msgPostingLeft; |
|
volatile ptrdiff_t tryingToPostLeft; // CONTEXT_POSTLEFT_* flags |
|
|
/* Pointer to the request message (containing the callback) */ | /* Pointer to the request message (containing the callback) */ |
Message* request; |
RequestMsg* request; |
|
Message* loadRequest; |
| |
/* chain processing */ | /* chain processing */ |
Context_Type chainType; |
Context_Type ctxType; |
| |
/* delayed invoke parameters */ | /* delayed invoke parameters */ |
MI_MethodDecl* md; | MI_MethodDecl* md; |
|
|
| |
/* Whether instanceName has been matched yet. */ | /* Whether instanceName has been matched yet. */ |
MI_Boolean matchedInstanceName; | MI_Boolean matchedInstanceName; |
|
|
|
// Uncomment when no longer using Selector |
|
// #if !defined(CONFIG_OS_WINDOWS) |
|
/* If Context_PostMessageLeft is trying to post from the IO thread */ |
|
MI_Boolean postingOnIoThread; |
|
// #endif |
|
|
|
/* Information needed if provider does not post a response instance as part of a modify command*/ |
|
MI_Instance * keyInstance; |
|
MI_Boolean postedModifyGetInstance; |
|
MI_Boolean postedModifyEnumInstance; |
|
MI_Boolean postedModifyInstance; |
} | } |
Context; | Context; |
| |
void Context_Init( |
typedef enum _ContextInitOptions |
Context* self, |
{ |
Provider* provider); |
ContextInit_CompleteOpen = 0, |
|
ContextInit_DelayOpen = 1, |
|
ContextInit_DontLeaveStrand = 2, |
|
ContextInit_NoInteraction = 3 |
|
} |
|
ContextInitOptions; |
|
|
| |
void Context_Destroy( |
MI_Result _Context_Init( |
Context* self); |
_Out_ Context* self, |
|
_In_opt_ Provider* provider, |
|
_Inout_opt_ InteractionOpenParams* interactionParams, |
|
ContextInitOptions options, |
|
Context_Type ctxType ); |
|
|
|
void _Context_Destroy( |
|
_Inout_ Context* self); |
|
|
|
MI_INLINE |
|
MI_Result Context_Init( |
|
_Out_ Context* self, |
|
_In_opt_ Provider* provider, |
|
_Inout_opt_ InteractionOpenParams* interactionParams) |
|
{ |
|
ContextInitOptions option = (NULL == interactionParams) ? ContextInit_NoInteraction : ContextInit_CompleteOpen; |
|
return _Context_Init( self, provider, interactionParams, option, CTX_TYPE_SINGLE_ITEM ); |
|
} |
|
|
|
MI_INLINE |
|
MI_Result Context_Init_ByType( |
|
_Out_ Context* self, |
|
_In_ Provider* provider, |
|
_Inout_ InteractionOpenParams* interactionParams, |
|
_In_ Context_Type ctxType ) |
|
{ |
|
return _Context_Init( self, provider, interactionParams, ContextInit_DontLeaveStrand, ctxType ); |
|
} |
|
|
|
MI_INLINE |
|
MI_Result Context_PartialInit( |
|
_Out_ Context* self, |
|
_In_ Provider* provider, |
|
_Inout_ InteractionOpenParams* interactionParams) |
|
{ |
|
return _Context_Init( self, provider, interactionParams, ContextInit_DelayOpen, CTX_TYPE_SINGLE_ITEM ); |
|
} |
|
|
|
void Context_CompleteOpen( |
|
_In_ Context* self, |
|
_In_ InteractionOpenParams* params, |
|
MI_Result result); |
|
|
|
void Context_Close( |
|
_In_ _Post_invalid_ Context* self ); |
|
|
|
// this is to be used by provmgr to post schema; not exposed to the provider |
|
void Context_PostSchema( |
|
_In_ Context* self, |
|
_In_ Message* msg); |
|
|
|
// Post a message to the component to the left |
|
void Context_PostMessageLeft( |
|
_In_ Context* self, |
|
_In_ Message* msg); |
| |
extern MI_ContextFT __mi_contextFT; | extern MI_ContextFT __mi_contextFT; |
| |
|
// |
|
// Initialize subscribe/unsubscribe context |
|
// |
|
MI_Result Subunsub_Context_Init( |
|
_Out_ Context* self, |
|
_In_ MI_Result* result, |
|
_In_ RequestMsg* msg); |
|
|
END_EXTERNC | END_EXTERNC |
| |
#endif /* _context_h */ | #endif /* _context_h */ |