<commit_before>/*
 * ccn/schedule.h
 * 
 * Copyright 2008 Palo Alto Research Center, Inc. All rights reserved.
 *
 * Event scheduling
 *
 * $Id$
 */

#ifndef CCN_SCHEDULE_DEFINED
#define CCN_SCHEDULE_DEFINED

#include <stdint.h>

struct ccn_schedule;
struct ccn_scheduled_event;

/*
 * This is a two-part absolute time value, which might be seconds and 
 * microseconds but does not have to be.  The interpretation depends
 * on the client-provided gettime object.  The distance into the future
 * for which events may be scheduled will be limited by the number of
 * micros that will fit in an int.
 */
struct ccn_timeval {
    long s;
    unsigned micros;
};

struct ccn_gettime;
typedef void (*ccn_gettime_action)(const struct ccn_gettime *, struct ccn_timeval *);
struct ccn_gettime {
    char descr[8];
    ccn_gettime_action gettime;
    unsigned micros_per_base;  /* e.g., 1000000 for seconds, microseconds */
    void *data;                /* for private use by gettime */
};

/*
 * The scheduled action may return a non-positive value
 * if the event should not be scheduled to occur again,
 * or a positive number of micros. If (flags & CCN_SCHEDULE_CANCEL),
 * the action should clean up and not reschedule itself.
 * The clienth is the one passed to ccn_schedule_create; event-specific
 * client data may be stored in ev->evdata and ev->evint.
 */
#define CCN_SCHEDULE_CANCEL 0x10
typedef int (*ccn_scheduled_action)(
    struct ccn_schedule *sched,
    void *clienth,
    struct ccn_scheduled_event *ev,
    int flags);

struct ccn_scheduled_event {
    ccn_scheduled_action action;
    void *evdata;
    intptr_t evint;
};

/*
 * Create and destroy
 */
struct ccn_schedule *ccn_schedule_create(void *clienth,
                                         const struct ccn_gettime *ccnclock);
void ccn_schedule_destroy(struct ccn_schedule **schedp);

/*
 * Accessor for the clock passed into create
 */
const struct ccn_gettime *ccn_schedule_get_gettime(struct ccn_schedule *);

/*
 * ccn_schedule_event: schedule a new event
 */
struct ccn_scheduled_event *ccn_schedule_event(
    struct ccn_schedule *sched,
    int micros,
    ccn_scheduled_action action,
    void *evdata,
    intptr_t evint);

/*
 * ccn_schedule_cancel: cancel a scheduled event
 * Cancels the event (calling action with CCN_SCHEDULE_CANCEL set)
 * Returns -1 if this is not possible.
 */
int ccn_schedule_cancel(struct ccn_schedule *, struct ccn_scheduled_event *);

/*
 * ccn_schedule_run: do any scheduled events
 * This executes any scheduled actions whose time has come.
 * The return value is the number of micros until the next
 * scheduled event, or -1 if there are none.
 */
int ccn_schedule_run(struct ccn_schedule *);

#endif<commit_msg>For more history, use git log -- schedule.h ../../../ccnd/include/ccn/schedule.h<commit_after>/*
 * ccn/schedule.h
 * 
 * Copyright 2008 Palo Alto Research Center, Inc. All rights reserved.
 *
 * Event scheduling
 *
 * $Id$
 */

#ifndef CCN_SCHEDULE_DEFINED
#define CCN_SCHEDULE_DEFINED

#include <stdint.h>

struct ccn_schedule;
struct ccn_scheduled_event;

/*
 * This is a two-part absolute time value, which might be seconds and 
 * microseconds but does not have to be.  The interpretation depends
 * on the client-provided gettime object.  The distance into the future
 * for which events may be scheduled will be limited by the number of
 * micros that will fit in an int.
 */
struct ccn_timeval {
    long s;
    unsigned micros;
};

struct ccn_gettime;
typedef void (*ccn_gettime_action)(const struct ccn_gettime *, struct ccn_timeval *);
struct ccn_gettime {
    char descr[8];
    ccn_gettime_action gettime;
    unsigned micros_per_base;  /* e.g., 1000000 for seconds, microseconds */
    void *data;                /* for private use by gettime */
};

/*
 * The scheduled action may return a non-positive value
 * if the event should not be scheduled to occur again,
 * or a positive number of micros. If (flags & CCN_SCHEDULE_CANCEL),
 * the action should clean up and not reschedule itself.
 * The clienth is the one passed to ccn_schedule_create; event-specific
 * client data may be stored in ev->evdata and ev->evint.
 */
#define CCN_SCHEDULE_CANCEL 0x10
typedef int (*ccn_scheduled_action)(
    struct ccn_schedule *sched,
    void *clienth,
    struct ccn_scheduled_event *ev,
    int flags);

struct ccn_scheduled_event {
    ccn_scheduled_action action;
    void *evdata;
    intptr_t evint;
};

/*
 * Create and destroy
 */
struct ccn_schedule *ccn_schedule_create(void *clienth,
                                         const struct ccn_gettime *ccnclock);
void ccn_schedule_destroy(struct ccn_schedule **schedp);

/*
 * Accessor for the clock passed into create
 */
const struct ccn_gettime *ccn_schedule_get_gettime(struct ccn_schedule *);

/*
 * ccn_schedule_event: schedule a new event
 */
struct ccn_scheduled_event *ccn_schedule_event(
    struct ccn_schedule *sched,
    int micros,
    ccn_scheduled_action action,
    void *evdata,
    intptr_t evint);

/*
 * ccn_schedule_cancel: cancel a scheduled event
 * Cancels the event (calling action with CCN_SCHEDULE_CANCEL set)
 * Returns -1 if this is not possible.
 */
int ccn_schedule_cancel(struct ccn_schedule *, struct ccn_scheduled_event *);

/*
 * ccn_schedule_run: do any scheduled events
 * This executes any scheduled actions whose time has come.
 * The return value is the number of micros until the next
 * scheduled event, or -1 if there are none.
 */
int ccn_schedule_run(struct ccn_schedule *);

#endif

{'fraction_non_alphanumeric': 0.07729905865314989, 'fraction_numerical': 0.006154960173787111, 'mean_word_length': 3.63506711409396, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3071478', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1732, 'n_words': 602}