本文整理汇总了C++中SCOPE函数的典型用法代码示例。如果您正苦于以下问题:C++ SCOPE函数的具体用法?C++ SCOPE怎么用?C++ SCOPE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SCOPE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scope_realize
static void scope_realize(GtkWidget *widget)
{
Scope *scope;
GdkWindowAttr attributes;
gint attributes_mask;
GdkGCValues gc_values;
GtkAllocation allocation;
GdkWindow *window;
GtkStyle *style;
g_return_if_fail(widget != NULL);
g_return_if_fail(IS_SCOPE(widget));
scope = SCOPE(widget);
gtk_widget_set_realized(widget, TRUE);
gtk_widget_get_allocation(widget, &allocation);
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = allocation.x;
attributes.y = allocation.y;
attributes.width = allocation.width;
attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual(widget);
attributes.colormap = gtk_widget_get_colormap(widget);
attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
gtk_widget_set_has_window(widget, TRUE);
window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask);
gtk_widget_set_window(widget, window);
gdk_window_set_user_data(window, scope);
gtk_widget_style_attach(widget);
style = gtk_widget_get_style(widget);
gtk_style_set_background(style, window, GTK_STATE_NORMAL);
/* gc's if necessary */
if (!gdk_colormap_alloc_color(style->colormap, &scope->tracecol,
FALSE, TRUE))
g_warning("unable to allocate color: ( %d %d %d )",
scope->tracecol.red, scope->tracecol.green, scope->tracecol.blue);
gc_values.foreground = scope->tracecol;
scope->trace_gc = gtk_gc_get(style->depth,
style->colormap,
&gc_values, GDK_GC_FOREGROUND);
if (!gdk_colormap_alloc_color(style->colormap, &scope->gridcol,
FALSE, TRUE))
g_warning("unable to allocate color: ( %d %d %d )",
scope->gridcol.red, scope->gridcol.green, scope->gridcol.blue);
gc_values.foreground = scope->gridcol;
scope->grid_gc = gtk_gc_get(style->depth,
style->colormap,
&gc_values, GDK_GC_FOREGROUND);
/* create backing store */
scope->pixmap = gdk_pixmap_new(window, SCOPE_WIDTH, SCOPE_HEIGHT, -1);
scope_send_configure(SCOPE(widget));
}
示例2: idle_callback
static gint idle_callback(gpointer data)
{
g_return_val_if_fail(data != NULL, FALSE);
g_return_val_if_fail(IS_SCOPE(data), FALSE);
SCOPE(data)->idlefunc = 0;
if (!gtk_widget_is_drawable(GTK_WIDGET(data)))
return FALSE;
draw(SCOPE(data));
return FALSE; /* don't call this callback again */
}
示例3: scope_load_init_scope
static int scope_load_init_scope(Unit *u) {
assert(u);
if (!unit_has_name(u, SPECIAL_INIT_SCOPE))
return 0;
u->transient = true;
u->perpetual = true;
/* init.scope is a bit special, as it has to stick around forever. Because of its special semantics we
* synthesize it here, instead of relying on the unit file on disk. */
u->default_dependencies = false;
u->ignore_on_isolate = true;
SCOPE(u)->kill_context.kill_signal = SIGRTMIN+14;
/* Prettify things, if we can. */
if (!u->description)
u->description = strdup("System and Service Manager");
if (!u->documentation)
(void) strv_extend(&u->documentation, "man:systemd(1)");
return 1;
}
示例4: scope_load
static int scope_load(Unit *u) {
Scope *s = SCOPE(u);
int r;
assert(s);
assert(u->load_state == UNIT_STUB);
if (!u->transient && !manager_is_reloading_or_reexecuting(u->manager))
return -ENOENT;
u->load_state = UNIT_LOADED;
r = unit_load_dropin(u);
if (r < 0)
return r;
r = unit_patch_contexts(u);
if (r < 0)
return r;
r = unit_set_default_slice(u);
if (r < 0)
return r;
r = scope_add_default_dependencies(s);
if (r < 0)
return r;
return scope_verify(s);
}
示例5: scope_start
static int scope_start(Unit *u) {
Scope *s = SCOPE(u);
int r;
assert(s);
if (s->state == SCOPE_FAILED)
return -EPERM;
if (s->state == SCOPE_STOP_SIGTERM ||
s->state == SCOPE_STOP_SIGKILL)
return -EAGAIN;
assert(s->state == SCOPE_DEAD);
if (!u->transient && UNIT(s)->manager->n_reloading <= 0)
return -ENOENT;
r = unit_realize_cgroup(u);
if (r < 0) {
log_error("Failed to realize cgroup: %s", strerror(-r));
return r;
}
r = cg_attach_many_everywhere(u->manager->cgroup_supported, u->cgroup_path, UNIT(s)->pids);
if (r < 0)
return r;
s->result = SCOPE_SUCCESS;
scope_set_state(s, SCOPE_RUNNING);
return 0;
}
示例6: scope_deserialize_item
static int scope_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
Scope *s = SCOPE(u);
assert(u);
assert(key);
assert(value);
assert(fds);
if (streq(key, "state")) {
ScopeState state;
state = scope_state_from_string(value);
if (state < 0)
log_unit_debug(u, "Failed to parse state value: %s", value);
else
s->deserialized_state = state;
} else if (streq(key, "was-abandoned")) {
int k;
k = parse_boolean(value);
if (k < 0)
log_unit_debug(u, "Failed to parse boolean value: %s", value);
else
s->was_abandoned = k;
} else
log_unit_debug(u, "Unknown serialization key: %s", key);
return 0;
}
示例7: scope_dispatch_timer
static int scope_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata) {
Scope *s = SCOPE(userdata);
assert(s);
assert(s->timer_event_source == source);
switch (s->state) {
case SCOPE_STOP_SIGTERM:
if (s->kill_context.send_sigkill) {
log_warning_unit(UNIT(s)->id, "%s stopping timed out. Killing.", UNIT(s)->id);
scope_enter_signal(s, SCOPE_STOP_SIGKILL, SCOPE_FAILURE_TIMEOUT);
} else {
log_warning_unit(UNIT(s)->id, "%s stopping timed out. Skipping SIGKILL.", UNIT(s)->id);
scope_enter_dead(s, SCOPE_FAILURE_TIMEOUT);
}
break;
case SCOPE_STOP_SIGKILL:
log_warning_unit(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id);
scope_enter_dead(s, SCOPE_FAILURE_TIMEOUT);
break;
default:
assert_not_reached("Timeout at wrong time.");
}
return 0;
}
示例8: scope_start
static int scope_start(Unit *u) {
Scope *s = SCOPE(u);
int r;
assert(s);
if (s->state == SCOPE_FAILED)
return -EPERM;
/* We can't fulfill this right now, please try again later */
if (s->state == SCOPE_STOP_SIGTERM ||
s->state == SCOPE_STOP_SIGKILL)
return -EAGAIN;
assert(s->state == SCOPE_DEAD);
if (!u->transient && UNIT(s)->manager->n_reloading <= 0)
return -ENOENT;
(void) unit_realize_cgroup(u);
(void) unit_reset_cpu_usage(u);
r = unit_attach_pids_to_cgroup(u);
if (r < 0) {
log_unit_warning_errno(UNIT(s), r, "Failed to add PIDs to scope's control group: %m");
scope_enter_dead(s, SCOPE_FAILURE_RESOURCES);
return r;
}
s->result = SCOPE_SUCCESS;
scope_set_state(s, SCOPE_RUNNING);
return 1;
}
示例9: scope_load
static int scope_load(Unit *u) {
Scope *s = SCOPE(u);
int r;
assert(s);
assert(u->load_state == UNIT_STUB);
if (!u->transient && UNIT(s)->manager->n_reloading <= 0)
return -ENOENT;
u->load_state = UNIT_LOADED;
r = unit_load_dropin(u);
if (r < 0)
return r;
r = unit_add_default_slice(u);
if (r < 0)
return r;
if (u->default_dependencies) {
r = scope_add_default_dependencies(s);
if (r < 0)
return r;
}
return scope_verify(s);
}
示例10: bus_scope_set_property
int bus_scope_set_property(
Unit *u,
const char *name,
sd_bus_message *message,
UnitSetPropertiesMode mode,
sd_bus_error *error) {
Scope *s = SCOPE(u);
int r;
assert(s);
assert(name);
assert(message);
r = bus_cgroup_set_property(u, &s->cgroup_context, name, message, mode, error);
if (r != 0)
return r;
if (u->load_state == UNIT_STUB) {
/* While we are created we still accept PIDs */
r = bus_scope_set_transient_property(s, name, message, mode, error);
if (r != 0)
return r;
r = bus_kill_context_set_transient_property(u, &s->kill_context, name, message, mode, error);
if (r != 0)
return r;
}
return 0;
}
示例11: scope_load
static int scope_load(Unit *u) {
Scope *s = SCOPE(u);
int r;
assert(s);
assert(u->load_state == UNIT_STUB);
if (!u->transient && !MANAGER_IS_RELOADING(u->manager))
/* Refuse to load non-transient scope units, but allow them while reloading. */
return -ENOENT;
r = scope_load_init_scope(u);
if (r < 0)
return r;
r = unit_load_fragment_and_dropin_optional(u);
if (r < 0)
return r;
if (u->load_state == UNIT_LOADED) {
r = unit_patch_contexts(u);
if (r < 0)
return r;
r = unit_set_default_slice(u);
if (r < 0)
return r;
r = scope_add_default_dependencies(s);
if (r < 0)
return r;
}
return scope_verify(s);
}
示例12: scope_enumerate_perpetual
static void scope_enumerate_perpetual(Manager *m) {
Unit *u;
int r;
assert(m);
/* Let's unconditionally add the "init.scope" special unit
* that encapsulates PID 1. Note that PID 1 already is in the
* cgroup for this, we hence just need to allocate the object
* for it and that's it. */
u = manager_get_unit(m, SPECIAL_INIT_SCOPE);
if (!u) {
r = unit_new_for_name(m, sizeof(Scope), SPECIAL_INIT_SCOPE, &u);
if (r < 0) {
log_error_errno(r, "Failed to allocate the special " SPECIAL_INIT_SCOPE " unit: %m");
return;
}
}
u->transient = true;
u->perpetual = true;
SCOPE(u)->deserialized_state = SCOPE_RUNNING;
unit_add_to_load_queue(u);
unit_add_to_dbus_queue(u);
}
示例13: scope_enumerate
static void scope_enumerate(Manager *m) {
Unit *u;
int r;
assert(m);
/* Let's unconditionally add the "init.scope" special unit
* that encapsulates PID 1. Note that PID 1 already is in the
* cgroup for this, we hence just need to allocate the object
* for it and that's it. */
u = manager_get_unit(m, SPECIAL_INIT_SCOPE);
if (!u) {
u = unit_new(m, sizeof(Scope));
if (!u) {
log_oom();
return;
}
r = unit_add_name(u, SPECIAL_INIT_SCOPE);
if (r < 0) {
unit_free(u);
log_error_errno(r, "Failed to add init.scope name");
return;
}
}
u->transient = true;
u->default_dependencies = false;
u->no_gc = true;
u->ignore_on_isolate = true;
u->refuse_manual_start = true;
u->refuse_manual_stop = true;
SCOPE(u)->deserialized_state = SCOPE_RUNNING;
SCOPE(u)->kill_context.kill_signal = SIGRTMIN+14;
/* Prettify things, if we can. */
if (!u->description)
u->description = strdup("System and Service Manager");
if (!u->documentation)
(void) strv_extend(&u->documentation, "man:systemd(1)");
unit_add_to_load_queue(u);
unit_add_to_dbus_queue(u);
}
示例14: scope_notify_cgroup_empty_event
static void scope_notify_cgroup_empty_event(Unit *u) {
Scope *s = SCOPE(u);
assert(u);
log_unit_debug(u, "cgroup is empty");
if (IN_SET(s->state, SCOPE_RUNNING, SCOPE_ABANDONED, SCOPE_STOP_SIGTERM, SCOPE_STOP_SIGKILL))
scope_enter_dead(s, SCOPE_SUCCESS);
}
示例15: scope_init
static void scope_init(Unit *u) {
Scope *s = SCOPE(u);
assert(u);
assert(u->load_state == UNIT_STUB);
s->timeout_stop_usec = u->manager->default_timeout_stop_usec;
u->ignore_on_isolate = true;
}