#define POPULATION_FLAG_LISTEN 0x01
#define POPULATION_FLAG_SHUTDOWN 0x02
+#define POPULATION_FLAG_EXPLORE 0x10
int flags;
pthread_t listen_thread_id;
return (0);
} /* }}} int population_set_serialization */
+int population_set_replacement_method (population_t *p, int method) /* {{{ */
+{
+ int status = 0;
+
+ if (p == NULL)
+ return (EINVAL);
+
+ pthread_mutex_lock (&p->lock);
+
+ if (method == POPULATION_REPLACEMENT_EXPLOIT)
+ p->flags &= ~POPULATION_FLAG_EXPLORE;
+ else if (method == POPULATION_REPLACEMENT_EXPLORE)
+ p->flags |= POPULATION_FLAG_EXPLORE;
+ else
+ status = EINVAL;
+
+ pthread_mutex_unlock (&p->lock);
+
+ return (0);
+} /* }}} int population_set_replacement_method */
+
int population_add_peer (population_t *p, const char *node, /* {{{ */
const char *port)
{
chance = (int) (((double) (chance_j + chance_pi))
* (rand() / (RAND_MAX + 1.0)));
+
+ if (p->flags & POPULATION_FLAG_EXPLORE)
+ chance *= .5;
+
if (chance < chance_j) /* j looses ;) */
{
void *temp0;
int population_set_serialization (population_t *p,
pi_serialize_f serialize, pi_unserialize_f unserialize);
+#define POPULATION_REPLACEMENT_EXPLOIT 1
+#define POPULATION_REPLACEMENT_EXPLORE 2
+int population_set_replacement_method (population_t *p, int method);
+
#define POPULATION_DEFAULT_PORT "46835"
int population_add_peer (population_t *p, const char *node, const char *port);
int population_start_listen_thread (population_t *p,