TipcEventCreate


Name

TipcEventCreate — create a user event

Synopsis

T_IPC_EVENT TipcEventCreate(dispatcher, data, event_func, event_arg) 
T_IPC_DISPATCHER dispatcher; 
T_PTR data; 
T_IPC_EVENT_FUNC event_func; 
T_PTR event_arg; 

Arguments

dispatcher — the dispatcher on which to invoke the event

data — data defined by the user that is associated with the event

event_func — the function to be invoked

event_arg — an optional argument to pass to the event_func

Return Values

A new event if successful, NULL otherwise.

Diagnostics

If TipcEventCreate fails, it returns FALSE and sets the global SmartSockets error number to:

Description

TipcEventCreate creates an event of type T_IPC_EVENT_USER to be invoked immediately on the specified dispatcher. The data can be any arbitrary user specified data. These events are useful for inter-thread communication.

Caution

None

See Also

TipcEventGetType, TipcEventGetData

Examples

This example creates a user event used to destroy and clean up a socket event:

void T_ENTRY eventDestroyFunc(T_IPC_EVENT event, T_IPC_EVENT_DATA 
data, T_PTR arg) 
{ 
  T_IPC_EVENT event_to_destroy; 
  T_INT4 socket = (T_INT4)arg; 
 
  if (!TipcEventGetData(event, &event_to_destroy)) { 
    return;  /* error */ 
  } 
 
  /* Destroy the socket event */ 
  if (!TipcEventDestroy(event_to_destroy)) { 
    return;  /* error */ 
  } 
   
  /* Close the socket */ 
  close(socket); 
 
} 
 
/* =========================================================== */ 
/*...code from main program is below */ 
 
socket_event = TipcEventCreateSocket(dispatcher, socket,  
                                     T_IO_CHECK_READ, 
                                     readFunc, T_NULL); 
if (socket_event == NULL) { 
  return;  /* error */ 
} 
 
/* 
 * This is the proper way to destroy an event in a dispatcher  
 * running in another thread, such as a detached dispatcher. 
 */ 
if (NULL == TipcEventCreate(dispatcher, (T_PTR)socket_event, 
                            eventDestroyFunc, 
                            (T_PTR)socket); 
  return;  /* error */ 
} 

TIBCO SmartSockets™ Application Programming Interface
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com