Typedefs | Functions
FIX::FIX Namespace Reference

Typedefs

typedef void *() THREAD_START_ROUTINE(void *)
 
typedef pthread_t thread_id
 

Functions

void string_replace (const std::string &oldValue, const std::string &newValue, std::string &value)
 
std::string string_toLower (const std::string &value)
 
std::string string_toUpper (const std::string &value)
 
std::string string_strip (const std::string &value)
 
void socket_init ()
 
void socket_term ()
 
int socket_bind (int socket, const char *hostname, int port)
 
int socket_createAcceptor (int port, bool reuse=false)
 
int socket_createConnector ()
 
int socket_connect (int s, const char *address, int port)
 
int socket_accept (int s)
 
ssize_t socket_recv (int s, char *buf, size_t length)
 
ssize_t socket_send (int s, const char *msg, size_t length)
 
void socket_close (int s)
 
bool socket_fionread (int s, int &bytes)
 
bool socket_disconnected (int s)
 
int socket_setsockopt (int s, int opt)
 
int socket_setsockopt (int s, int opt, int optval)
 
int socket_getsockopt (int s, int opt, int &optval)
 
int socket_fcntl (int s, int opt, int arg)
 
int socket_getfcntlflag (int s, int arg)
 
int socket_setfcntlflag (int s, int arg)
 
void socket_setnonblock (int s)
 
bool socket_isValid (int socket)
 
bool socket_isBad (int s)
 
void socket_invalidate (int &socket)
 
short socket_hostport (int socket)
 
const char * socket_hostname (int socket)
 
const char * socket_hostname (const char *name)
 
const char * socket_peername (int socket)
 
std::pair< int, int > socket_createpair ()
 
tm time_gmtime (const time_t *t)
 
tm time_localtime (const time_t *t)
 
bool thread_spawn (THREAD_START_ROUTINE func, void *var, thread_id &thread)
 
bool thread_spawn (THREAD_START_ROUTINE func, void *var)
 
void thread_join (thread_id thread)
 
void thread_detach (thread_id thread)
 
thread_id thread_self ()
 
void process_sleep (double s)
 
std::string file_separator ()
 
void file_mkdir (const char *path)
 
FILE * file_fopen (const char *path, const char *mode)
 
void file_fclose (FILE *file)
 
bool file_exists (const char *path)
 
void file_unlink (const char *path)
 
int file_rename (const char *oldpath, const char *newpath)
 
std::string file_appendpath (const std::string &path, const std::string &file)
 

Typedef Documentation

◆ thread_id

typedef pthread_t FIX::FIX::thread_id

Definition at line 190 of file DOMDocument.h.

◆ THREAD_START_ROUTINE

typedef void*() FIX::FIX::THREAD_START_ROUTINE(void *)

Definition at line 183 of file DOMDocument.h.

Function Documentation

◆ file_appendpath()

std::string FIX::FIX::file_appendpath ( const std::string &  path,
const std::string &  file 
)

Definition at line 551 of file Utility.cpp.

References FIX::file_separator().

Referenced by FIX::FileStore::FileStore(), and FIX::FileLog::init().

552 {
553  const char last = path[path.size()-1];
554  if( last == '/' || last == '\\' )
555  return std::string(path) + file;
556  else
557  return std::string(path) + file_separator() + file;
558 }
std::string file_separator()
Definition: Utility.cpp:480

◆ file_exists()

bool FIX::FIX::file_exists ( const char *  path)

Definition at line 525 of file Utility.cpp.

526 {
527  std::ifstream stream;
528  stream.open( path, std::ios_base::in );
529  if( stream.is_open() )
530  {
531  stream.close();
532  return true;
533  }
534  return false;
535 }

◆ file_fclose()

void FIX::FIX::file_fclose ( FILE *  file)

Definition at line 520 of file Utility.cpp.

Referenced by FIX::FileLog::backup().

521 {
522  fclose( file );
523 }

◆ file_fopen()

FILE* FIX::FIX::file_fopen ( const char *  path,
const char *  mode 
)

Definition at line 509 of file Utility.cpp.

Referenced by FIX::FileLog::backup(), FIX::FileStore::open(), and FIX::FileStore::populateCache().

510 {
511 #if( _MSC_VER >= 1400 )
512  FILE* result = 0;
513  fopen_s( &result, path, mode );
514  return result;
515 #else
516  return fopen( path, mode );
517 #endif
518 }

◆ file_mkdir()

void FIX::FIX::file_mkdir ( const char *  path)

Definition at line 489 of file Utility.cpp.

Referenced by FIX::FileStore::FileStore(), and FIX::FileLog::init().

490 {
491  int length = (int)strlen( path );
492  std::string createPath = "";
493 
494  for( const char* pos = path; (pos - path) <= length; ++pos )
495  {
496  createPath += *pos;
497  if( *pos == '/' || *pos == '\\' || (pos - path) == length )
498  {
499  #ifdef _MSC_VER
500  _mkdir( createPath.c_str() );
501  #else
502  // use umask to override rwx for all
503  mkdir( createPath.c_str(), 0777 );
504  #endif
505  }
506  }
507 }

◆ file_rename()

int FIX::FIX::file_rename ( const char *  oldpath,
const char *  newpath 
)

Definition at line 546 of file Utility.cpp.

Referenced by FIX::FileLog::backup().

547 {
548  return rename( oldpath, newpath );
549 }

◆ file_separator()

std::string FIX::FIX::file_separator ( )

Definition at line 480 of file Utility.cpp.

Referenced by FIX::file_appendpath().

481 {
482 #ifdef _MSC_VER
483  return "\\";
484 #else
485  return "/";
486 #endif
487 }

◆ file_unlink()

void FIX::FIX::file_unlink ( const char *  path)

Definition at line 537 of file Utility.cpp.

Referenced by FIX::FileStore::open().

538 {
539 #ifdef _MSC_VER
540  _unlink( path );
541 #else
542  unlink( path );
543 #endif
544 }

◆ process_sleep()

void FIX::FIX::process_sleep ( double  s)

Definition at line 466 of file Utility.cpp.

Referenced by FIX::ThreadedSocketInitiator::onStart(), FIX::ThreadedSocketConnection::setSession(), FIX::SocketMonitor::sleepIfEmpty(), FIX::Initiator::stop(), and FIX::Acceptor::stop().

467 {
468 #ifdef _MSC_VER
469  Sleep( (long)(s * 1000) );
470 #else
471  timespec time, remainder;
472  double intpart;
473  time.tv_nsec = (long)(modf(s, &intpart) * 1e9);
474  time.tv_sec = (int)intpart;
475  while( nanosleep(&time, &remainder) == -1 )
476  time = remainder;
477 #endif
478 }

◆ socket_accept()

int FIX::FIX::socket_accept ( int  s)

Definition at line 164 of file Utility.cpp.

References FIX::socket_isValid().

Referenced by FIX::SocketServer::accept(), FIX::socket_createpair(), and FIX::ThreadedSocketAcceptor::socketAcceptorThread().

165 {
166  if ( !socket_isValid( s ) ) return -1;
167  return accept( s, 0, 0 );
168 }
bool socket_isValid(int socket)
Definition: Utility.cpp:277

◆ socket_bind()

int FIX::FIX::socket_bind ( int  socket,
const char *  hostname,
int  port 
)

Definition at line 103 of file Utility.cpp.

Referenced by FIX::SocketConnector::connect(), and FIX::ThreadedSocketConnection::connect().

104 {
105  sockaddr_in address;
106  socklen_t socklen;
107 
108  address.sin_family = PF_INET;
109  address.sin_port = htons( port );
110  if ( !hostname || !*hostname )
111  address.sin_addr.s_addr = INADDR_ANY;
112  else
113  address.sin_addr.s_addr = inet_addr( hostname );
114  socklen = sizeof( address );
115 
116  return bind( socket, reinterpret_cast < sockaddr* > ( &address ),
117  socklen );
118 }

◆ socket_close()

void FIX::FIX::socket_close ( int  s)

◆ socket_connect()

int FIX::FIX::socket_connect ( int  s,
const char *  address,
int  port 
)

Definition at line 148 of file Utility.cpp.

References FIX::socket_hostname().

Referenced by FIX::SocketConnector::connect(), FIX::ThreadedSocketConnection::connect(), and FIX::socket_createpair().

149 {
150  const char* hostname = socket_hostname( address );
151  if( hostname == 0 ) return -1;
152 
153  sockaddr_in addr;
154  addr.sin_family = PF_INET;
155  addr.sin_port = htons( port );
156  addr.sin_addr.s_addr = inet_addr( hostname );
157 
158  int result = connect( socket, reinterpret_cast < sockaddr* > ( &addr ),
159  sizeof( addr ) );
160 
161  return result;
162 }
const char * socket_hostname(const char *name)
Definition: Utility.cpp:324

◆ socket_createAcceptor()

int FIX::FIX::socket_createAcceptor ( int  port,
bool  reuse = false 
)

Definition at line 120 of file Utility.cpp.

References FIX::socket_setsockopt().

Referenced by FIX::SocketServer::add(), FIX::ThreadedSocketAcceptor::onInitialize(), and FIX::socket_createpair().

121 {
122  int socket = ::socket( PF_INET, SOCK_STREAM, 0 );
123  if ( socket < 0 ) return -1;
124 
125  sockaddr_in address;
126  socklen_t socklen;
127 
128  address.sin_family = PF_INET;
129  address.sin_port = htons( port );
130  address.sin_addr.s_addr = INADDR_ANY;
131  socklen = sizeof( address );
132  if( reuse )
133  socket_setsockopt( socket, SO_REUSEADDR );
134 
135  int result = bind( socket, reinterpret_cast < sockaddr* > ( &address ),
136  socklen );
137  if ( result < 0 ) return -1;
138  result = listen( socket, SOMAXCONN );
139  if ( result < 0 ) return -1;
140  return socket;
141 }
int socket_setsockopt(int s, int opt, int optval)
Definition: Utility.cpp:218

◆ socket_createConnector()

int FIX::FIX::socket_createConnector ( )

Definition at line 143 of file Utility.cpp.

Referenced by FIX::SocketConnector::connect(), FIX::ThreadedSocketInitiator::doConnect(), and FIX::socket_createpair().

144 {
145  return ::socket( PF_INET, SOCK_STREAM, IPPROTO_TCP );
146 }

◆ socket_createpair()

std::pair<int, int> FIX::FIX::socket_createpair ( )

Definition at line 366 of file Utility.cpp.

References FIX::socket_accept(), FIX::socket_close(), FIX::socket_connect(), FIX::socket_createAcceptor(), FIX::socket_createConnector(), FIX::socket_hostname(), and FIX::socket_hostport().

Referenced by FIX::SocketMonitor::SocketMonitor().

367 {
368 #ifdef _MSC_VER
369  int acceptor = socket_createAcceptor(0, true);
370  const char* host = socket_hostname( acceptor );
371  short port = socket_hostport( acceptor );
372  int client = socket_createConnector();
373  socket_connect( client, "localhost", port );
374  int server = socket_accept( acceptor );
375  socket_close(acceptor);
376  return std::pair<int, int>( client, server );
377 #else
378  int pair[2];
379  socketpair( AF_UNIX, SOCK_STREAM, 0, pair );
380  return std::pair<int, int>( pair[0], pair[1] );
381 #endif
382 }
int socket_connect(int socket, const char *address, int port)
Definition: Utility.cpp:148
int socket_accept(int s)
Definition: Utility.cpp:164
short socket_hostport(int socket)
Definition: Utility.cpp:304
int socket_createConnector()
Definition: Utility.cpp:143
const char * socket_hostname(const char *name)
Definition: Utility.cpp:324
int socket_createAcceptor(int port, bool reuse)
Definition: Utility.cpp:120
void socket_close(int s)
Definition: Utility.cpp:180

◆ socket_disconnected()

bool FIX::FIX::socket_disconnected ( int  s)

Definition at line 202 of file Utility.cpp.

203 {
204  char byte;
205  return ::recv (s, &byte, sizeof (byte), MSG_PEEK) <= 0;
206 }

◆ socket_fcntl()

int FIX::FIX::socket_fcntl ( int  s,
int  opt,
int  arg 
)

Definition at line 250 of file Utility.cpp.

Referenced by FIX::socket_getfcntlflag(), and FIX::socket_setfcntlflag().

251 {
252  return ::fcntl( s, opt, arg );
253 }

◆ socket_fionread()

bool FIX::FIX::socket_fionread ( int  s,
int &  bytes 
)

Definition at line 190 of file Utility.cpp.

191 {
192  bytes = 0;
193 #if defined(_MSC_VER)
194  return ::ioctlsocket( s, FIONREAD, &( ( unsigned long& ) bytes ) ) == 0;
195 #elif defined(USING_STREAMS)
196  return ::ioctl( s, I_NREAD, &bytes ) >= 0;
197 #else
198  return ::ioctl( s, FIONREAD, &bytes ) == 0;
199 #endif
200 }

◆ socket_getfcntlflag()

int FIX::FIX::socket_getfcntlflag ( int  s,
int  arg 
)

Definition at line 255 of file Utility.cpp.

References FIX::socket_fcntl().

Referenced by FIX::socket_setfcntlflag().

256 {
257  return socket_fcntl( s, F_GETFL, arg );
258 }
int socket_fcntl(int s, int opt, int arg)
Definition: Utility.cpp:250

◆ socket_getsockopt()

int FIX::FIX::socket_getsockopt ( int  s,
int  opt,
int &  optval 
)

Definition at line 233 of file Utility.cpp.

Referenced by FIX::ThreadedSocketAcceptor::socketAcceptorThread().

234 {
235  int level = SOL_SOCKET;
236  if( opt == TCP_NODELAY )
237  level = IPPROTO_TCP;
238 
239 #ifdef _MSC_VER
240  int length = sizeof(int);
241 #else
242  socklen_t length = sizeof(socklen_t);
243 #endif
244 
245  return ::getsockopt( s, level, opt,
246  ( char* ) & optval, & length );
247 }

◆ socket_hostname() [1/2]

const char* FIX::FIX::socket_hostname ( int  socket)

Definition at line 314 of file Utility.cpp.

Referenced by FIX::socket_connect(), and FIX::socket_createpair().

315 {
316  struct sockaddr_in addr;
317  socklen_t len = sizeof(addr);
318  if( getsockname(socket, (struct sockaddr*)&addr, &len) < 0 )
319  return 0;
320 
321  return inet_ntoa( addr.sin_addr );
322 }

◆ socket_hostname() [2/2]

const char* FIX::FIX::socket_hostname ( const char *  name)

Definition at line 324 of file Utility.cpp.

325 {
326  struct hostent* host_ptr = 0;
327  struct in_addr** paddr;
328  struct in_addr saddr;
329 
330 #if( GETHOSTBYNAME_R_INPUTS_RESULT || GETHOSTBYNAME_R_RETURNS_RESULT )
331  hostent host;
332  char buf[1024];
333  int error;
334 #endif
335 
336  saddr.s_addr = inet_addr( name );
337  if ( saddr.s_addr != ( unsigned ) - 1 ) return name;
338 
339 #if GETHOSTBYNAME_R_INPUTS_RESULT
340  gethostbyname_r( name, &host, buf, sizeof(buf), &host_ptr, &error );
341 #elif GETHOSTBYNAME_R_RETURNS_RESULT
342  host_ptr = gethostbyname_r( name, &host, buf, sizeof(buf), &error );
343 #else
344  host_ptr = gethostbyname( name );
345 #endif
346 
347  if ( host_ptr == 0 ) return 0;
348 
349  paddr = ( struct in_addr ** ) host_ptr->h_addr_list;
350  return inet_ntoa( **paddr );
351 }

◆ socket_hostport()

short FIX::FIX::socket_hostport ( int  socket)

Definition at line 304 of file Utility.cpp.

Referenced by FIX::socket_createpair().

305 {
306  struct sockaddr_in addr;
307  socklen_t len = sizeof(addr);
308  if( getsockname(socket, (struct sockaddr*)&addr, &len) < 0 )
309  return 0;
310 
311  return ntohs( addr.sin_port );
312 }

◆ socket_init()

void FIX::FIX::socket_init ( )

Definition at line 81 of file Utility.cpp.

Referenced by FIX::SocketMonitor::SocketMonitor(), FIX::ThreadedSocketAcceptor::ThreadedSocketAcceptor(), and FIX::ThreadedSocketInitiator::ThreadedSocketInitiator().

82 {
83 #ifdef _MSC_VER
84  WORD version = MAKEWORD( 2, 2 );
85  WSADATA data;
86  WSAStartup( version, &data );
87 #else
88  struct sigaction sa;
89  sa.sa_handler = SIG_IGN;
90  sigemptyset( &sa.sa_mask );
91  sa.sa_flags = 0;
92  sigaction( SIGPIPE, &sa, 0 );
93 #endif
94 }

◆ socket_invalidate()

void FIX::FIX::socket_invalidate ( int &  socket)

Definition at line 295 of file Utility.cpp.

Referenced by FIX::SocketServer::close().

296 {
297 #ifdef _MSC_VER
298  socket = INVALID_SOCKET;
299 #else
300  socket = -1;
301 #endif
302 }

◆ socket_isBad()

bool FIX::FIX::socket_isBad ( int  s)

Definition at line 287 of file Utility.cpp.

288 {
289  struct stat buf;
290  fstat( s, &buf );
291  return errno == EBADF;
292 }

◆ socket_isValid()

bool FIX::FIX::socket_isValid ( int  socket)

Definition at line 277 of file Utility.cpp.

Referenced by FIX::SocketServer::block(), FIX::HttpServer::onConnect(), FIX::SocketAcceptor::onConnect(), and FIX::socket_accept().

278 {
279 #ifdef _MSC_VER
280  return socket != INVALID_SOCKET;
281 #else
282  return socket >= 0;
283 #endif
284 }

◆ socket_peername()

const char* FIX::FIX::socket_peername ( int  socket)

Definition at line 353 of file Utility.cpp.

Referenced by FIX::SocketAcceptor::onConnect(), and FIX::ThreadedSocketAcceptor::socketAcceptorThread().

354 {
355  struct sockaddr_in addr;
356  socklen_t len = sizeof(addr);
357  if( getpeername( socket, (struct sockaddr*)&addr, &len ) < 0 )
358  return "UNKNOWN";
359  char* result = inet_ntoa( addr.sin_addr );
360  if( result )
361  return result;
362  else
363  return "UNKNOWN";
364 }

◆ socket_recv()

ssize_t FIX::FIX::socket_recv ( int  s,
char *  buf,
size_t  length 
)

Definition at line 170 of file Utility.cpp.

Referenced by FIX::SocketMonitor::processReadSet(), FIX::HttpConnection::read(), FIX::ThreadedSocketConnection::read(), and FIX::SocketConnection::readFromSocket().

171 {
172  return recv( s, buf, length, 0 );
173 }

◆ socket_send()

ssize_t FIX::FIX::socket_send ( int  s,
const char *  msg,
size_t  length 
)

Definition at line 175 of file Utility.cpp.

Referenced by FIX::SocketConnection::processQueue(), FIX::ThreadedSocketConnection::send(), FIX::HttpConnection::send(), and FIX::SocketMonitor::signal().

176 {
177  return send( s, msg, length, 0 );
178 }

◆ socket_setfcntlflag()

int FIX::FIX::socket_setfcntlflag ( int  s,
int  arg 
)

Definition at line 260 of file Utility.cpp.

References FIX::socket_fcntl(), and FIX::socket_getfcntlflag().

Referenced by FIX::socket_setnonblock().

261 {
262  int oldValue = socket_getfcntlflag( s, arg );
263  oldValue |= arg;
264  return socket_fcntl( s, F_SETFL, arg );
265 }
int socket_getfcntlflag(int s, int arg)
Definition: Utility.cpp:255
int socket_fcntl(int s, int opt, int arg)
Definition: Utility.cpp:250

◆ socket_setnonblock()

void FIX::FIX::socket_setnonblock ( int  s)

Definition at line 268 of file Utility.cpp.

References FIX::socket_setfcntlflag().

Referenced by FIX::SocketMonitor::addConnect(), FIX::SocketMonitor::addRead(), FIX::SocketMonitor::addWrite(), and FIX::SocketMonitor::SocketMonitor().

269 {
270 #ifdef _MSC_VER
271  u_long opt = 1;
272  ::ioctlsocket( socket, FIONBIO, &opt );
273 #else
274  socket_setfcntlflag( socket, O_NONBLOCK );
275 #endif
276 }
int socket_setfcntlflag(int s, int arg)
Definition: Utility.cpp:260

◆ socket_setsockopt() [1/2]

int FIX::FIX::socket_setsockopt ( int  s,
int  opt 
)

Definition at line 208 of file Utility.cpp.

Referenced by FIX::SocketServer::accept(), FIX::SocketServer::add(), FIX::SocketConnector::connect(), FIX::ThreadedSocketInitiator::doConnect(), FIX::ThreadedSocketAcceptor::onInitialize(), FIX::socket_createAcceptor(), and FIX::ThreadedSocketAcceptor::socketAcceptorThread().

209 {
210 #ifdef _MSC_VER
211  BOOL optval = TRUE;
212 #else
213  int optval = 1;
214 #endif
215  return socket_setsockopt( s, opt, optval );
216 }
int socket_setsockopt(int s, int opt, int optval)
Definition: Utility.cpp:218

◆ socket_setsockopt() [2/2]

int FIX::FIX::socket_setsockopt ( int  s,
int  opt,
int  optval 
)

Definition at line 218 of file Utility.cpp.

219 {
220  int level = SOL_SOCKET;
221  if( opt == TCP_NODELAY )
222  level = IPPROTO_TCP;
223 
224 #ifdef _MSC_VER
225  return ::setsockopt( s, level, opt,
226  ( char* ) & optval, sizeof( optval ) );
227 #else
228  return ::setsockopt( s, level, opt,
229  &optval, sizeof( optval ) );
230 #endif
231 }

◆ socket_term()

void FIX::FIX::socket_term ( )

Definition at line 96 of file Utility.cpp.

Referenced by FIX::SocketMonitor::~SocketMonitor(), FIX::ThreadedSocketAcceptor::~ThreadedSocketAcceptor(), and FIX::ThreadedSocketInitiator::~ThreadedSocketInitiator().

97 {
98 #ifdef _MSC_VER
99  WSACleanup();
100 #endif
101 }

◆ string_replace()

void FIX::FIX::string_replace ( const std::string &  oldValue,
const std::string &  newValue,
std::string &  value 
)

Definition at line 40 of file Utility.cpp.

43 {
44  for( std::string::size_type pos = value.find(oldValue);
45  pos != std::string::npos;
46  pos = value.find(oldValue, pos) )
47  {
48  value.replace( pos, oldValue.size(), newValue );
49  pos += newValue.size();
50  }
51 }

◆ string_strip()

std::string FIX::FIX::string_strip ( const std::string &  value)

Definition at line 67 of file Utility.cpp.

Referenced by FIX::operator>>(), FIX::Dictionary::setBool(), FIX::Dictionary::setDouble(), FIX::Dictionary::setInt(), FIX::Dictionary::setString(), and FIX::splitSection().

68 {
69  if( !value.size() )
70  return value;
71 
72  size_t startPos = value.find_first_not_of(" \t\r\n");
73  size_t endPos = value.find_last_not_of(" \t\r\n");
74 
75  if( startPos == std::string::npos )
76  return value;
77 
78  return std::string( value, startPos, endPos - startPos + 1 );
79 }

◆ string_toLower()

std::string FIX::FIX::string_toLower ( const std::string &  value)

Definition at line 60 of file Utility.cpp.

61 {
62  std::string copy = value;
63  std::transform( copy.begin(), copy.end(), copy.begin(), tolower );
64  return copy;
65 }

◆ string_toUpper()

std::string FIX::FIX::string_toUpper ( const std::string &  value)

Definition at line 53 of file Utility.cpp.

Referenced by FIX::Dictionary::getString(), FIX::Dictionary::has(), FIX::SessionFactory::processFixtDataDictionaries(), FIX::Dictionary::setBool(), FIX::Dictionary::setDouble(), FIX::Dictionary::setInt(), and FIX::Dictionary::setString().

54 {
55  std::string copy = value;
56  std::transform( copy.begin(), copy.end(), copy.begin(), toupper );
57  return copy;
58 }

◆ thread_detach()

void FIX::FIX::thread_detach ( thread_id  thread)

Definition at line 447 of file Utility.cpp.

Referenced by FIX::ThreadedSocketInitiator::removeThread(), and FIX::ThreadedSocketAcceptor::removeThread().

448 {
449 #ifdef _MSC_VER
450  CloseHandle((HANDLE)thread);
451 #else
452  pthread_t t = thread;
453  pthread_detach( t );
454 #endif
455 }

◆ thread_join()

void FIX::FIX::thread_join ( thread_id  thread)

Definition at line 437 of file Utility.cpp.

Referenced by FIX::ThreadedSocketInitiator::onStop(), FIX::ThreadedSocketAcceptor::onStop(), FIX::HttpServer::stop(), FIX::Initiator::stop(), and FIX::Acceptor::stop().

438 {
439 #ifdef _MSC_VER
440  WaitForSingleObject( ( void* ) thread, INFINITE );
441  CloseHandle((HANDLE)thread);
442 #else
443  pthread_join( ( pthread_t ) thread, 0 );
444 #endif
445 }

◆ thread_self()

thread_id FIX::FIX::thread_self ( )

Definition at line 457 of file Utility.cpp.

458 {
459 #ifdef _MSC_VER
460  return (unsigned)GetCurrentThread();
461 #else
462  return pthread_self();
463 #endif
464 }

◆ thread_spawn() [1/2]

bool FIX::FIX::thread_spawn ( THREAD_START_ROUTINE  func,
void *  var,
thread_id thread 
)

Definition at line 416 of file Utility.cpp.

Referenced by FIX::ThreadedSocketInitiator::doConnect(), FIX::ThreadedSocketAcceptor::onStart(), FIX::ThreadedSocketAcceptor::socketAcceptorThread(), FIX::HttpServer::start(), FIX::Initiator::start(), FIX::Acceptor::start(), and FIX::thread_spawn().

417 {
418 #ifdef _MSC_VER
419  thread_id result = 0;
420  unsigned int id = 0;
421  result = _beginthreadex( NULL, 0, func, var, 0, &id );
422  if ( result == 0 ) return false;
423 #else
424  thread_id result = 0;
425  if( pthread_create( &result, 0, func, var ) != 0 ) return false;
426 #endif
427  thread = result;
428  return true;
429 }
pthread_t thread_id
Definition: DOMDocument.h:190

◆ thread_spawn() [2/2]

bool FIX::FIX::thread_spawn ( THREAD_START_ROUTINE  func,
void *  var 
)

Definition at line 431 of file Utility.cpp.

References FIX::thread_spawn().

432 {
433  thread_id thread = 0;
434  return thread_spawn( func, var, thread );
435 }
pthread_t thread_id
Definition: DOMDocument.h:190
bool thread_spawn(THREAD_START_ROUTINE func, void *var)
Definition: Utility.cpp:431

◆ time_gmtime()

tm FIX::FIX::time_gmtime ( const time_t *  t)

Definition at line 384 of file Utility.cpp.

Referenced by FIX::DateTime::fromUtcTimeT().

385 {
386 #ifdef _MSC_VER
387  #if( _MSC_VER >= 1400 )
388  tm result;
389  gmtime_s( &result, t );
390  return result;
391  #else
392  return *gmtime( t );
393  #endif
394 #else
395  tm result;
396  return *gmtime_r( t, &result );
397 #endif
398 }

◆ time_localtime()

tm FIX::FIX::time_localtime ( const time_t *  t)

Definition at line 400 of file Utility.cpp.

Referenced by FIX::DateTime::fromLocalTimeT().

401 {
402 #ifdef _MSC_VER
403  #if( _MSC_VER >= 1400 )
404  tm result;
405  localtime_s( &result, t );
406  return result;
407  #else
408  return *localtime( t );
409  #endif
410 #else
411  tm result;
412  return *localtime_r( t, &result );
413 #endif
414 }

Generated on Wed Aug 28 2019 14:13:46 for QuickFIX by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001