void
StdDispatch_Test::nameArgs2()
{
  invokena((NamedArg("arg1", 42), NamedArg("arg2", &RCS("Blub"))));
  invokena(NamedArg("arg1", 42));
  invokena((NamedArg("arg1", 42), 
            NamedArg("arg2", &RCS("Blub")),
            NamedArg("arg1", 42),
            NamedArg("arg2", &RCS("Blub"))));
}
コード例 #2
0
void	*start_meeting(void *p)
{
  unsigned int	rcs;
  unsigned int	lcs;
  t_sceptiques	*philosopher;

  philosopher = (t_sceptiques*)p;
  while (philosopher->rice)
    {
      pthread_mutex_lock(&g_m);
      lcs = g_chopsticks[philosopher->id];
      rcs = g_chopsticks[RCS(philosopher->id)];
      if (philosopher->status != EATING && lcs == 0 && rcs == 0)
	eat(philosopher);
      else if (philosopher->status != EATING &&
	       philosopher->status != THINKING &&
	       lcs == 0)
	think(philosopher);
      else
	rest(philosopher);
    }
  philosopher->status = LEFT;
  pthread_exit(NULL);
  return 0;
}
コード例 #3
0
void	eat(t_sceptiques *philosopher)
{
  g_chopsticks[philosopher->id] = 1;
  g_chopsticks[RCS(philosopher->id)] = 1;
  pthread_mutex_unlock(&g_m);
  philosopher->status = EATING;
  usleep(250000);
  (philosopher->hunger > philosopher->rice ?
   philosopher->rice = 0 :
   (philosopher->rice -= philosopher->hunger));
  ++(philosopher->digestion);
  ++(philosopher->stamina);
  --(philosopher->hunger);
  if (philosopher->rice <= 0)
    philosopher->rice = 0;
  pthread_mutex_lock(&g_m);
  g_chopsticks[philosopher->id] = 0;
  g_chopsticks[RCS(philosopher->id)] = 0;
  pthread_mutex_unlock(&g_m);
}
コード例 #4
0
ファイル: RCString_Char.c プロジェクト: virpool/RayLanguage
 * Author Kucheruavyu Ilya ([email protected])
 * 05/11/2015 Ukraine Kharkiv
 *  _         _ _ _
 * | |       (_|_) |
 * | | _____  _ _| |__   __ _
 * | |/ / _ \| | | '_ \ / _` |
 * |   < (_) | | | |_) | (_| |
 * |_|\_\___/| |_|_.__/ \__,_|
 *          _/ |
 *         |__/
 **/

#include "RCString_Char.h"

inline method(void, replaceCSubstrings, RCString), char *toReplace, char *replacer) {
    RCString *toReplaceTemp = RCS(toReplace);
    RCString *replacerTemp = RCS(replacer);
    $(object, m(replaceSubstrings, RCString)), toReplaceTemp, replacerTemp);
    deallocator(toReplaceTemp);
    deallocator(replacerTemp);
}

inline constMethod(size_t, numberOfCSubstrings, RCString), const char * string) {
    RCString *temp   = RCS(string);
    size_t    result = $(object, m(numberOfSubstrings, RCString)), temp);
    deallocator(temp);
    return result;
}

inline constMethod(rbool, isContainsCSubstring, RCString), char *string) {
    RCString *temp = RCS(string);