//-------------------------------------------------------------------------------------------------- void fdMon_Report ( void* safeRef, ///< [in] Safe Reference for the FD Monitor object for the fd. uint32_t eventFlags ///< [in] OR'd together event flags from epoll_wait(). ) //-------------------------------------------------------------------------------------------------- { le_event_QueueFunction(DispatchToHandler, safeRef, (void*)(ssize_t)eventFlags); }
void ipcTest_EchoReference ( ipcTest_ServerCmdRef_t serverCmdPtr, ipcTest_SimpleRef_t InRef ) { le_event_QueueFunction(AsyncServer_EchoReferenceRespond, serverCmdPtr, InRef); }
void ipcTest_EchoSmallBitMask ( ipcTest_ServerCmdRef_t serverCmdPtr, ipcTest_SmallBitMask_t InValue ) { le_event_QueueFunction(AsyncServer_EchoSmallBitMaskRespond, serverCmdPtr, (void*)InValue); }
void ipcTest_EchoSimple ( ipcTest_ServerCmdRef_t serverCmdPtr, int32_t InValue ) { // Weird cast avoids warnings on Ubuntu 14.04 le_event_QueueFunction(AsyncServer_EchoSimpleRespond, serverCmdPtr, (void*)((size_t)InValue)); }
void ipcTest_EchoLargeEnum ( ipcTest_ServerCmdRef_t serverCmdPtr, ipcTest_LargeEnum_t InValue ) { ipcTest_LargeEnum_t* valuePtr = le_mem_ForceAlloc(ValuePool); *valuePtr = InValue; le_event_QueueFunction(AsyncServer_EchoLargeEnumRespond, serverCmdPtr, valuePtr); }
void ipcTest_EchoTriggerEvent ( ipcTest_ServerCmdRef_t serverCmdPtr, int32_t cookie ///< [IN] ) { if (EchoEventHandlerPtr) { EchoEventHandlerPtr(cookie, EchoEventContextPtr); } le_event_QueueFunction(AsyncServer_EchoTriggerEventRespond, serverCmdPtr, NULL); }
void ipcTest_EchoString ( ipcTest_ServerCmdRef_t serverCmdPtr, const char* InString, size_t OutStringSize ) { // Cap output string size at maximum size of buffer if (OutStringSize > MAX_VALUE_SIZE) { OutStringSize = MAX_VALUE_SIZE; } char* OutString = le_mem_ForceAlloc(ValuePool); strncpy(OutString, InString, OutStringSize); OutString[OutStringSize-1] = '\0'; le_event_QueueFunction(AsyncServer_EchoStringRespond, serverCmdPtr, OutString); }
//-------------------------------------------------------------------------------------------------- le_json_ParsingSessionRef_t le_json_ParseString ( const char *jsonString, ///< JSON string to parse. le_json_EventHandler_t eventHandler, ///< Function to call when normal parsing events happen. le_json_ErrorHandler_t errorHandler, ///< Function to call when errors happen. void* opaquePtr ///< Opaque pointer to be fetched by handlers using le_json_GetOpaquePtr(). ) { // Create a Parser. Parser_t* parserPtr = NewParser(eventHandler, errorHandler, opaquePtr); parserPtr->fd = -1; parserPtr->jsonString = jsonString; le_event_QueueFunction((le_event_DeferredFunc_t) &StringEventHandler, parserPtr, NULL); // Create the top-level context and push it onto the context stack. PushContext(parserPtr, LE_JSON_CONTEXT_DOC, eventHandler); return parserPtr; }
void* NewThread ( void* contextPtr ) { // Init IPC for the new thread ConnectService(); banner("New Thread Started"); // Wait a few seconds so that the output of the two tests does not overlap. It makes it // much easier to verify the results. Yes, this could be done with timers, but no harm // just using sleep() here, since this is not the main thread. sleep(10); // Start the test once the Event Loop is running. le_event_QueueFunction(StartTestNewThread, NULL, NULL); le_event_RunLoop(); return NULL; }
//-------------------------------------------------------------------------------------------------- void fdMon_Report ( void* safeRef, ///< [in] Safe Reference for the FD Monitor object for the fd. uint32_t eventFlags ///< [in] OR'd together event flags from epoll_wait(). ) //-------------------------------------------------------------------------------------------------- { // Queue up function calls for any flags set in epoll's event. if (eventFlags & EPOLLIN) { le_event_QueueFunction(DispatchToHandler, safeRef, (void*)LE_EVENT_FD_READABLE); } if (eventFlags & EPOLLPRI) { le_event_QueueFunction(DispatchToHandler, safeRef, (void*)LE_EVENT_FD_READABLE_URGENT); } if (eventFlags & EPOLLOUT) { le_event_QueueFunction(DispatchToHandler, safeRef, (void*)LE_EVENT_FD_WRITEABLE); } if (eventFlags & EPOLLHUP) { le_event_QueueFunction(DispatchToHandler, safeRef, (void*)LE_EVENT_FD_WRITE_HANG_UP); } if (eventFlags & EPOLLRDHUP) { le_event_QueueFunction(DispatchToHandler, safeRef, (void*)LE_EVENT_FD_READ_HANG_UP); } if (eventFlags & EPOLLERR) { le_event_QueueFunction(DispatchToHandler, safeRef, (void*)LE_EVENT_FD_ERROR); } LE_CRIT_IF(eventFlags & ~(EPOLLIN | EPOLLPRI | EPOLLOUT | EPOLLHUP | EPOLLRDHUP | EPOLLERR), "Extra flags found in fd event report. (%xd)", eventFlags); }