Migrated sender_t to METHOD/INIT macros
This commit is contained in:
+18
-19
@@ -63,10 +63,8 @@ struct private_sender_t {
|
|||||||
condvar_t *sent;
|
condvar_t *sent;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
METHOD(sender_t, send_, void,
|
||||||
* implements sender_t.send
|
private_sender_t *this, packet_t *packet)
|
||||||
*/
|
|
||||||
static void send_(private_sender_t *this, packet_t *packet)
|
|
||||||
{
|
{
|
||||||
host_t *src, *dst;
|
host_t *src, *dst;
|
||||||
|
|
||||||
@@ -81,7 +79,7 @@ static void send_(private_sender_t *this, packet_t *packet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of private_sender_t.send_packets.
|
* Job callback function to send packets
|
||||||
*/
|
*/
|
||||||
static job_requeue_t send_packets(private_sender_t * this)
|
static job_requeue_t send_packets(private_sender_t * this)
|
||||||
{
|
{
|
||||||
@@ -109,10 +107,8 @@ static job_requeue_t send_packets(private_sender_t * this)
|
|||||||
return JOB_REQUEUE_DIRECT;
|
return JOB_REQUEUE_DIRECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(sender_t, destroy, void,
|
||||||
* Implementation of sender_t.destroy.
|
private_sender_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_sender_t *this)
|
|
||||||
{
|
{
|
||||||
/* send all packets in the queue */
|
/* send all packets in the queue */
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
@@ -134,18 +130,21 @@ static void destroy(private_sender_t *this)
|
|||||||
*/
|
*/
|
||||||
sender_t * sender_create()
|
sender_t * sender_create()
|
||||||
{
|
{
|
||||||
private_sender_t *this = malloc_thing(private_sender_t);
|
private_sender_t *this;
|
||||||
|
|
||||||
this->public.send = (void(*)(sender_t*,packet_t*))send_;
|
INIT(this,
|
||||||
this->public.destroy = (void(*)(sender_t*)) destroy;
|
.public = {
|
||||||
|
.send = _send_,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.list = linked_list_create(),
|
||||||
|
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
|
||||||
|
.got = condvar_create(CONDVAR_TYPE_DEFAULT),
|
||||||
|
.sent = condvar_create(CONDVAR_TYPE_DEFAULT),
|
||||||
|
.job = callback_job_create((callback_job_cb_t)send_packets,
|
||||||
|
this, NULL, NULL),
|
||||||
|
);
|
||||||
|
|
||||||
this->list = linked_list_create();
|
|
||||||
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
|
|
||||||
this->got = condvar_create(CONDVAR_TYPE_DEFAULT);
|
|
||||||
this->sent = condvar_create(CONDVAR_TYPE_DEFAULT);
|
|
||||||
|
|
||||||
this->job = callback_job_create((callback_job_cb_t)send_packets,
|
|
||||||
this, NULL, NULL);
|
|
||||||
charon->processor->queue_job(charon->processor, (job_t*)this->job);
|
charon->processor->queue_job(charon->processor, (job_t*)this->job);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
|
|||||||
Reference in New Issue
Block a user